Skip to content

Commit

Permalink
Smoothen maps, get rid of double colors
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jul 25, 2017
1 parent ba79a78 commit 2f1fe00
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Binary file modified colormaps.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions example.js
Expand Up @@ -23,11 +23,9 @@ function drawColorMaps (colormap, name, height) {
/*
* Build up the color ranges and add text
*/

for (var j = 0; j < n; j++) {
c.fillStyle = colormap[j]; // start ind at index 0
c.fillRect(j*10, height, 10, 40);

}
c.fillStyle = '#262626';
c.font = '16px Helvetica';
Expand Down
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -28,7 +28,7 @@ function createColormap (spec) {

if ( !isPlainObject(spec) ) spec = {};

nshades = spec.nshades || 72;
nshades = (spec.nshades || 72) - 1;
format = spec.format || 'hex';

colormap = spec.colormap;
Expand Down Expand Up @@ -116,6 +116,10 @@ function createColormap (spec) {
])
}
}

//add 1 step as last value
colors.push(cmap[cmap.length - 1].rgb.concat(alpha[1]))

if (format === 'hex') colors = colors.map( rgb2hex );
if (format === 'rgbaString') colors = colors.map( rgbaStr );

Expand Down

0 comments on commit 2f1fe00

Please sign in to comment.