[] travis-url [] coveralls-url
HSV/RGB color conversion utility library. HSV filter, coloring filter, gradients generating.
- R,G,B,A -- integer channel value (0..255);
- h -- hue value (0..359);
- s,v,a -- saturation, volume, alpha value (0..1);
- g -- gamma value;
- RGB -- [ R, G, B ];
- RGBA -- [ R, G, B, A ];
- IRGBA -- 0xRRGGBBAA;
- IRGB -- 0xRRGGBB;
- data -- array of bytes;
- addr -- offset in an array of bytes.
set Gamma correction value
Converts RGB to HSV. Returns array [ h, s, v ].
Returns [ R, G, B ].
Returns [ R, G, B, A ].
Returns [ h, s, v, a ].
Return CSS hex color string -- '#RRGGBB'.
Return SVN hex color string -- '#RRGGBBAA'.
Returns [ R, G, B ]. Eats '#RGB', '#RGBA', '#RRGGBB' and '#RRGGBBAA' formats.
Returns [ R, G, B, A ]. Eats '#RGB', '#RGBA', '#RRGGBB' and '#RRGGBBAA' formats.
Returns [ R, G, B ].
Returns [ R, G, B, A ].
Returns 0xRRGGBBAA.
Put or mix in RGBA to the RGB bitmap array (data).
Put or mix in RGBA to the RGBA bitmap array (data).
Applyes HSV filter to the bitmap pixel.
Applyes Colorify filter to the bitmap pixel.
There are special case for v < 0. A result volume will be calculated by the formula (.21*r + .72*g + .07*b) * -val
.
- {stops} -- Object with color stops like:
{ 0: '#000', 4000: '#1234', 6000: 0x33445566, 10000: [ 255, 255, 255, 255 ] }
where, keys of object should be numeric value in bounds between 0 and 10000, that means from 0 to 1.0.
- {fn(position, RGBA)} -- callback function
Example:
> var c = require('nano-color');
c.gradient(0, 10, {
0: '#000',
4000: '#1234',
6500: 0x33445566,
10000: [ 255, 255, 7, 255 ]
}, function (pos, RGBA) {
console.log('%s: [ %s ]', pos, RGBA.join(', '));
});
will produce console output:
0: [ 0, 0, 0, 255 ]
1: [ 4, 9, 13, 208 ]
2: [ 9, 17, 26, 162 ]
3: [ 13, 26, 38, 115 ]
4: [ 17, 34, 51, 68 ]
5: [ 31, 48, 65, 82 ]
6: [ 48, 65, 82, 99 ]
7: [ 80, 95, 74, 124 ]
8: [ 138, 148, 52, 168 ]
9: [ 197, 202, 29, 211 ]
10: [ 255, 255, 7, 255 ]