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

node-colorfactory

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-colorfactory - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.jshintignore

2

package.json
{
"name": "node-colorfactory",
"version": "0.1.1",
"version": "0.1.2",
"description": "Awesome methods for working with colors in javascript.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -0,1 +1,3 @@

[![Build Status](https://secure.travis-ci.org/Krinkle/node-colorfactory.png)](http://travis-ci.org/Krinkle/node-colorfactory)
ColorFactory

@@ -2,0 +4,0 @@ =================

@@ -7,3 +7,3 @@ /*!

*/
(function (global) {
(function () {

@@ -138,3 +138,3 @@ var ColorHelper, ColorFactory,

*/
diverging: function (startColor, count) {
diverging: function () {
/* @todo */

@@ -144,3 +144,3 @@ }

// Expose: NodeJS or Browser
// Expose: Server or browser
if (typeof module !== 'undefined' && module.exports) {

@@ -150,5 +150,5 @@ ColorHelper = require('./ColorHelper');

} else {
ColorHelper = global.ColorHelper;
global.ColorFactory = ColorFactory;
ColorHelper = this.ColorHelper;
this.ColorFactory = ColorFactory;
}
}(this));
}());
/*!
* ColorHelper
*/
(function (global) {
(function () {

@@ -240,8 +240,8 @@ /* Local variables */

} else {
var_2 = (l < 0.5) ? l * ( 1 + s ) : (( l + s ) - ( s * l ));
var_2 = (l < 0.5) ? l * (1 + s) : ((l + s) - (s * l));
var_1 = 2 * l - var_2;
r = 255 * h2rgb(var_1, var_2, h + ( 1 / 3 ));
r = 255 * h2rgb(var_1, var_2, h + (1 / 3));
g = 255 * h2rgb(var_1, var_2, h);
b = 255 * h2rgb(var_1, var_2, h - ( 1 / 3 ));
b = 255 * h2rgb(var_1, var_2, h - (1 / 3));
}

@@ -261,12 +261,12 @@

if (( 6 * vH ) < 1) {
return ( v1 + ( v2 - v1 ) * 6 * vH );
if ((6 * vH) < 1) {
return (v1 + (v2 - v1) * 6 * vH);
}
if (( 2 * vH ) < 1) {
return ( v2 );
if ((2 * vH) < 1) {
return v2;
}
if (( 3 * vH ) < 2) {
return ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 );
if ((3 * vH) < 2) {
return (v1 + (v2 - v1) * ((2 / 3) - vH) * 6);
}

@@ -279,3 +279,3 @@

var h = Math.round(n).toString(16);
if (h.length == 1) {
if (h.length === 1) {
h = '0' + h;

@@ -318,3 +318,3 @@ }

*/
function RGBtoHSL(rgb) {
function rgbToHsl(rgb) {
var r, g, b, max, min, d, h, s, l,

@@ -341,14 +341,14 @@ cache;

// Chromatic data...
s = d / ( l < 0.5 ? ( max + min ) : ( 2 - max - min ));
s = d / (l < 0.5 ? (max + min) : (2 - max - min));
var del_R = ( ( ( max - r ) / 6 ) + ( d / 2 ) ) / d,
del_G = ( ( ( max - g ) / 6 ) + ( d / 2 ) ) / d,
del_B = ( ( ( max - b ) / 6 ) + ( d / 2 ) ) / d;
var del_R = (((max - r) / 6) + (d / 2)) / d,
del_G = (((max - g) / 6) + (d / 2)) / d,
del_B = (((max - b) / 6) + (d / 2)) / d;
if (r == max) {
if (r === max) {
h = del_B - del_G;
} else if (g == max) {
h = ( 1 / 3 ) + del_R - del_B;
} else if (b == max) {
h = ( 2 / 3 ) + del_G - del_R;
} else if (g === max) {
h = (1 / 3) + del_R - del_B;
} else if (b === max) {
h = (2 / 3) + del_G - del_R;
}

@@ -381,9 +381,9 @@

var rgb = ColorHelper.strToHexColor(s);
return RGBtoHSL(rgb);
return rgbToHsl(rgb);
},
strToHexColor: function (str) {
if (str.substr(0, 1) == '#' && str.length == 7) {
if (str.substr(0, 1) === '#' && str.length === 7) {
colorCache(str).hex = '' + str;
} else if (str.substr(0, 1) == '#' && str.length == 4) {
} else if (str.substr(0, 1) === '#' && str.length === 4) {
colorCache(str).hex = '#' + str.substr(1, 1) + str.substr(1, 1) +

@@ -448,8 +448,8 @@ str.substr(2, 1) + str.substr(2, 1) +

// Expose: NodeJS or Browser
// Expose: Server or browser
if (typeof module !== 'undefined' && module.exports) {
module.exports = ColorHelper;
} else {
global.ColorHelper = ColorHelper;
this.ColorHelper = ColorHelper;
}
}(this));
}());

@@ -21,9 +21,9 @@ QUnit.module('ColorFactory');

$.each([
['#6d00ff','#0000ff','#0090ff'],
['#ff7400','#ff0000','#cd0074'],
['#9fee00','#ffff00','#ffd300'],
['#19d408','#96fe04','#EAFF04'],
['#FE0435','#FC04C5','#8B16FB'],
['#FF7590','#FD74DF','#BF7EFD'],
['#0a8ccd','#04FBD1','#04fb56']
['#6d00ff', '#0000ff', '#0090ff'],
['#ff7400', '#ff0000', '#cd0074'],
['#9fee00', '#ffff00', '#ffd300'],
['#19d408', '#96fe04', '#EAFF04'],
['#FE0435', '#FC04C5', '#8B16FB'],
['#FF7590', '#FD74DF', '#BF7EFD'],
['#0a8ccd', '#04FBD1', '#04fb56']
], function (index, item) {

@@ -30,0 +30,0 @@ QUnit.colorTest.closeMatch('analogous (from: ' + item[1] + ')',

@@ -44,15 +44,15 @@ QUnit.module('ColorHelper', {

QUnit.test('rgbToHSL()', function (assert) {
assert.deepEqual('#ffffff'.toHSL(), [0,0,100], 'convert white to hsl');
assert.deepEqual('#ffffff'.toHSL(), [0, 0, 100], 'convert white to hsl');
assert.deepEqual('#000000'.toHSL(), [0,0,0], 'convert black to hsl');
assert.deepEqual('#000000'.toHSL(), [0, 0, 0], 'convert black to hsl');
assert.deepEqual('#ff0000'.toHSL(), [0,100,50], 'convert red to hsl');
assert.deepEqual('#ff0000'.toHSL(), [0, 100, 50], 'convert red to hsl');
assert.deepEqual('#00ff00'.toHSL(), [120,100,50], 'convert green to hsl');
assert.deepEqual('#00ff00'.toHSL(), [120, 100, 50], 'convert green to hsl');
assert.deepEqual('#0000ff'.toHSL(), [240,100,50], 'convert blue to hsl');
assert.deepEqual('#0000ff'.toHSL(), [240, 100, 50], 'convert blue to hsl');
assert.deepEqual('#800'.toHSL(), [0, 100, 27], 'convert #800 to hsl');
assert.deepEqual('#336699'.toHSL(), [210,50,40], 'convert #336699 to hsl');
assert.deepEqual('#336699'.toHSL(), [210, 50, 40], 'convert #336699 to hsl');
});

@@ -101,27 +101,31 @@

QUnit.test('saturate()', function (assert) {
assert.match('#800'.saturate(0), /#8[789a]0000/, 'do nothing with zero');
assert.match('#800'.saturate(0), /#8[789a]0000/, 'do nothing with zero');
assert.equal(ColorHelper.hslToHexColor(120, 30, 90).saturate(20), '#d9f2d9',
'saturate(hsl(120, 30%, 90%), 20%)'
);
assert.equal(
ColorHelper.hslToHexColor(120, 30, 90).saturate(20),
'#d9f2d9',
'saturate(hsl(120, 30%, 90%), 20%)'
);
assert.match('#855'.saturate(20), /#9[de]3f3f/, 'saturate(#855, 20%) => #9e3f3f');
assert.match('#855'.saturate(20), /#9[de]3f3f/, 'saturate(#855, 20%) => #9e3f3f');
assert.match('#000'.saturate(20), /#000000/, 'saturate(#000, 20%) => #000');
assert.match('#000'.saturate(20), /#000000/, 'saturate(#000, 20%) => #000');
assert.match('#fff'.saturate(20), /#ffffff/, 'saturate(#fff, 20%) => #ffffff');
assert.match('#fff'.saturate(20), /#ffffff/, 'saturate(#fff, 20%) => #ffffff');
assert.match('#8a8'.saturate(100), /#33ff33/, 'saturate(#8a8,100%) => #33ff33');
assert.match('#8a8'.saturate(100), /#33ff33/, 'saturate(#8a8,100%) => #33ff33');
assert.match('#8a8'.saturate(0), /#88aa88/, 'saturate(#8a8, 0%) => #88aa88');
assert.match('#8a8'.saturate(0), /#88aa88/, 'saturate(#8a8, 0%) => #88aa88');
assert.equal(ColorHelper.hslToHexColor(120, 30, 90).saturate(-20), '#e3e8e3',
'desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)'
);
assert.equal(
ColorHelper.hslToHexColor(120, 30, 90).saturate(-20),
'#e3e8e3',
'desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)'
);
assert.match('#855'.saturate(-20), /#716a6a/, 'desaturate 855 to #726b6b');
assert.match('#000'.saturate(-20), /#000000/, 'desaturate 000 to black');
assert.match('#fff'.saturate(-20), /#ffffff/, 'desaturate 000 to white');
assert.match('#8a8'.saturate(-100), /#999999/, 'desaturate 000 to white');
assert.match('#855'.saturate(-20), /#716a6a/, 'desaturate(#855, 20%) => #726b6b');
assert.match('#855'.saturate(-20), /#716a6a/, 'desaturate 855 to #726b6b');
assert.match('#000'.saturate(-20), /#000000/, 'desaturate 000 to black');
assert.match('#fff'.saturate(-20), /#ffffff/, 'desaturate 000 to white');
assert.match('#8a8'.saturate(-100), /#999999/, 'desaturate 000 to white');
assert.match('#855'.saturate(-20), /#716a6a/, 'desaturate(#855, 20%) => #726b6b');
});

@@ -98,3 +98,3 @@ /* Utilities */

if (colors.length < 2) {
QUnit.pushFailure('assert.beDistinguishable expects two or more colors.', sourceFromStacktrace());
QUnit.pushFailure('assert.beDistinguishable expects two or more colors.');
return;

@@ -101,0 +101,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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