Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segmented-colormap module #52

Closed
jywarren opened this issue Jul 8, 2017 · 1 comment
Closed

segmented-colormap module #52

jywarren opened this issue Jul 8, 2017 · 1 comment
Assignees

Comments

@jywarren
Copy link
Member

jywarren commented Jul 8, 2017

we can use PixelManipulation, and copy this directly from Infragram.org (https://infragram.org/sandbox/):

https://github.com/publiclab/infragram-js/blob/master/public/infragram.js#L88-L114

that method returns a new function which maps an incoming value (0-255) to an outgoing value, and can be run on each pixel.

Colormap functions are based on a nested array:

https://github.com/publiclab/infragram-js/blob/master/public/infragram.js#L212-L214

var c = segmented_colormap([[0, [0, 0, 255], [38, 195, 195]], [0.5, [0, 150, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 50, 50]]]);
c(0) // => [0, 0, 255]

then we can make lots of different segmented_colormaps! Gradient colormaps too, but later; this is simpler for now.

screenshot 2017-07-08 at 2 05 29 pm

Also the Fastie colormap:

colormap_fastie = segmented_colormap([[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]);
 ```
@ccpandhare
Copy link
Collaborator

Added in #57!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants