Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nano-color

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-color - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

48

index.js

@@ -257,19 +257,22 @@ "use strict";

/* --------------------------------------------------------------------------------------- */
// (pos_a, pos_b, gr/*object*/, callback(/*this, */ pos, color/*[r,g,b]*/))
exports.gradient = function gradient(pos_a, pos_b, gr, callback) {
// (pos_a, pos_b, colors/*object*/, callback(/*this, */ pos, color/*[r,g,b]*/))
exports.gradient = function gradient(pos_a, pos_b, colors, callback) {
function obj2rgba(some) {
switch (typeof some) {
function obj2rgba(color) {
switch (typeof color) {
case 'string':
return hex2rgba(some);
return hex2rgba(color);
case 'number':
return rgba2array(some);
return rgba2array(color);
case 'object':
if (some instanceof Array) {
if (some.length < 4)
return [ some[0], some[1], some[2], 255 ];
} else
throw TypeError('wrong color type');
if (color instanceof Array) {
switch (color.length) {
case 4:
return color;
case 3:
return [ color[0], color[1], color[2], 255 ];
}
}
}
return some;
throw TypeError('wrong color type');
}

@@ -298,6 +301,8 @@ function getLineAB(x1, y1, dx, dy) {

var w = pos_b - pos_a, i = 0, x1, c1, x2, c2, c = [], line = [];
for (var p in gr) {
x2 = pos_a + w*p/10000;
c2 = obj2rgba(gr[p]);
var w = pos_b - pos_a, i = 0,
x1, c1, x2, c2, line = [ 0, 0, 0, 0 ];
for (var stop in colors) {
x2 = pos_a + w*stop/10000;
c2 = obj2rgba(colors[stop]);
if (i > 0) {

@@ -310,5 +315,10 @@ var dx = x2 - x1;

for (var ix = (x1+.9999)|0, ie = x2|0; ix < ie; ++ix)
callback.call(this, ix, color(ix));
callback.call(this, ie, ie < pos_b ? mix(x2-ie, color(ie), c2) : c2);
for (var ix = (x1/*+.9999*/)|0, ie = x2|0; ix < ie; ++ix)
callback(ix, color(ix));
if (ie === pos_b)
callback(ie, c2);
else
if (ix !== ie)
callback(ie, mix(x2-ie, color(ie), c2));
}

@@ -315,0 +325,0 @@ x1 = x2;

{
"name": "nano-color",
"version": "1.0.5",
"version": "1.0.6",
"description": "HSV &lt;-> RGB colors conversion utility library. HSV filter, coloring filter, gradients generating.",

@@ -5,0 +5,0 @@ "keywords" : [ "HSV", "RGB", "RGBA", "hsv-filter", "coloring-filter", "gradient" ],

@@ -104,4 +104,4 @@ # nano-color

4000: '#1234',
6000: 0x33445566,
10000: [ 255, 255, 255, 255 ]
6500: 0x33445566,
10000: [ 255, 255, 7, 255 ]
}, function (pos, RGBA) {

@@ -111,2 +111,3 @@ console.log('%s: [ %s ]', pos, RGBA.join(', '));

```
will produce console output:

@@ -119,10 +120,8 @@ ```

4: [ 17, 34, 51, 68 ]
4: [ 17, 34, 51, 68 ]
5: [ 34, 51, 68, 85 ]
6: [ 51, 68, 85, 102 ]
6: [ 51, 68, 85, 102 ]
7: [ 102, 115, 128, 140 ]
8: [ 153, 162, 170, 179 ]
9: [ 204, 208, 213, 217 ]
10: [ 255, 255, 255, 255 ]
5: [ 31, 48, 65, 82 ]
6: [ 22, 41, 96, 80 ]
7: [ 80, 95, 74, 124 ]
8: [ 138, 148, 52, 168 ]
9: [ 197, 202, 29, 211 ]
10: [ 255, 255, 7, 255 ]
```

@@ -129,0 +128,0 @@

@@ -89,6 +89,6 @@ var c = require('../index.js'),

return 'null';
var o = '{';
var o = [];
for (var id in a)
o += id+':'+ts(a[id], radix, 1);
return o + '}';
o.push(id+':'+ts(a[id], radix, 1));
return '{' + o.join(',') + '}';
}

@@ -376,13 +376,27 @@ break;

}, [
[ 0, 9, { 0:0xff0000, 4000: [ 80, 80, 80, 80], 6000:'#6666', 10000: [ 255, 0, 204 ] } ], [
0, 255, 0, 0,
22, 206, 22, 22,
44, 158, 44, 44,
72, 97, 72, 72,
85, 85, 85, 85,
100, 100, 100, 100,
128, 85, 119, 128,
170, 57, 147, 170,
213, 28, 176, 213,
255, 0, 204, 255
[ 0, 10, { 0: '#000', 4000: '#1234', 6000: 0x33445566, 10000: [ 255, 255, 255, 255 ] } ], [
0, 0, 0, 255,
4, 9, 13, 208,
9, 17, 26, 162,
13, 26, 38, 115,
17, 34, 51, 68,
34, 51, 68, 85,
51, 68, 85, 102,
102, 115, 128, 140,
153, 162, 170, 179,
204, 208, 213, 217,
255, 255, 255, 255
],
[ 0, 10, { 0: '#000', 4002: '#1234', 6500: 0x33445566, 10000: [ 255, 255, 7, 255 ] } ], [
0, 0, 0, 255,
4, 8, 13, 208,
8, 17, 25, 162,
13, 25, 38, 115,
17, 34, 51, 68,
31, 48, 65, 82,
22, 41, 96, 80,
80, 95, 74, 124,
138, 148, 52, 168,
197, 202, 29, 211,
255, 255, 7, 255
]

@@ -389,0 +403,0 @@ ], 10, 10, 1.6);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc