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.2 to 0.1.4

.jscsrc

67

package.json
{
"name": "node-colorfactory",
"version": "0.1.2",
"description": "Awesome methods for working with colors in javascript.",
"keywords": [
"colors",
"rgb",
"hsl",
"hex",
"util",
"utilities"
],
"homepage": "https://github.com/Krinkle/node-colorfactory",
"bugs": "https://github.com/Krinkle/node-colorfactory/issues",
"author": {
"name": "Andrew Peterson"
},
"contributors": [{
"name": "Timo Tijhof",
"web": "https://github.com/Krinkle"
}],
"main": "./node-colorfactory.js",
"repository": {
"type": "git",
"url": "git://github.com/Krinkle/node-colorfactory.git"
},
"dependencies": {}
"name": "node-colorfactory",
"version": "0.1.4",
"description": "Awesome methods for working with colors in javascript.",
"keywords": [
"colors",
"rgb",
"hsl",
"hex",
"util",
"utilities"
],
"homepage": "https://github.com/Krinkle/node-colorfactory",
"bugs": "https://github.com/Krinkle/node-colorfactory/issues",
"author": {
"name": "Andrew Peterson"
},
"contributors": [
{
"name": "Timo Tijhof",
"web": "https://github.com/Krinkle"
}
],
"main": "./node-colorfactory.js",
"repository": {
"type": "git",
"url": "git://github.com/Krinkle/node-colorfactory.git"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-jshint": "0.10.0",
"grunt-jscs": "1.0.0",
"grunt-karma": "0.9.0",
"karma": "0.12.28",
"karma-firefox-launcher": "0.1.3",
"karma-phantomjs-launcher": "0.1.4",
"karma-qunit": "0.1.4",
"qunitjs": "1.16.0"
},
"scripts": {
"test": "grunt test"
}
}

@@ -1,2 +0,2 @@

[![Build Status](https://secure.travis-ci.org/Krinkle/node-colorfactory.png)](http://travis-ci.org/Krinkle/node-colorfactory)
[![Build Status](https://travis-ci.org/Krinkle/node-colorfactory.svg?branch=master)](https://travis-ci.org/Krinkle/node-colorfactory) [![npm](https://img.shields.io/npm/v/colorfactory.svg?style=flat)](https://www.npmjs.com/package/colorfactory)

@@ -11,8 +11,7 @@ ColorFactory

```bash
npm install node-colorfactory
npm install colorfactory
```
Clone the repo, `git clone git@github.com:Krinkle/node-colorfactory.git`, or [download the latest master](https://github.com/Krinkle/node-colorfactory/zipball/master).
Clone the repo, `git clone --recursive https://github.com/Krinkle/node-colorfactory.git`.
Versioning

@@ -29,3 +28,2 @@ ----------

Bug tracker

@@ -32,0 +30,0 @@ -----------

@@ -31,6 +31,9 @@ /*!

analogous: function (color, angle) {
if (!angle) angle = 30;
var hsl = ColorHelper.rgbToHSL(color);
var hsl, color0, color2;
if (!angle) {
angle = 30;
}
hsl = ColorHelper.rgbToHSL(color);
hsl[0] = (hsl[0] + angle) % 360;
var color0 = ColorHelper.hslToHexColor(hsl);
color0 = ColorHelper.hslToHexColor(hsl);
color0 = ColorHelper.darken(color0, 8);

@@ -40,3 +43,3 @@ color0 = ColorHelper.saturate(color0, -6);

hsl[0] = (hsl[0] - angle + 360) % 360;
var color2 = ColorHelper.hslToHexColor(hsl);
color2 = ColorHelper.hslToHexColor(hsl);
return [color0, color, color2];

@@ -62,12 +65,13 @@ },

interpolate: function (color1, colorN, steps) {
var hsl1 = ColorHelper.rgbToHSL(color1);
var hslN = ColorHelper.rgbToHSL(colorN);
var delta = [];
for (var d in hsl1) {
delta.push((hslN[d] - hsl1[d]) / (steps - 1));
var d, i,
hsl = ColorHelper.rgbToHSL(color1),
hslN = ColorHelper.rgbToHSL(colorN),
delta = [],
colors = [];
for (d in hsl) {
delta.push((hslN[d] - hsl[d]) / (steps - 1));
}
var hsl = hsl1;
var colors = [];
for (var i = 0; i < steps; i++) {
for (i = 0; i < steps; i++) {
colors.push(ColorHelper.hslToHexColor(hsl));

@@ -94,7 +98,10 @@ for (d in hsl) {

}
var hsl = ColorHelper.rgbToHSL(refColor);
var i,
hsl = ColorHelper.rgbToHSL(refColor),
colors = [];
hsl[1] = Math.max(60, hsl[1]);
hsl[2] = Math.max(40, hsl[2]);
hsl[2] = Math.min(70, hsl[2]);
var i, colors = [];
for (i = 0; i < count; i++) {

@@ -117,7 +124,10 @@ colors.push(ColorHelper.hslToHexColor(hsl));

sequential: function (startColor, endColor, count) {
var hsl = ColorHelper.rgbToHSL(startColor);
var lightness,
hsl = ColorHelper.rgbToHSL(startColor);
if (count === undefined) {
count = endColor;
var lightness = hsl[2] - 20 * count;
if (lightness < 0) lightness = 100 - hsl[2];
lightness = hsl[2] - 20 * count;
if (lightness < 0) {
lightness = 100 - hsl[2];
}
endColor = ColorHelper.hslToHexColor([hsl[0], hsl[1], lightness]);

@@ -124,0 +134,0 @@ }

@@ -317,3 +317,4 @@ /*!

var r, g, b, max, min, d, h, s, l,
cache;
cache,
del_R, del_G, del_B;

@@ -340,5 +341,5 @@ rgb = ColorHelper.hexToRGB(rgb);

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;
del_R = (((max - r) / 6) + (d / 2)) / d;
del_G = (((max - g) / 6) + (d / 2)) / d;
del_B = (((max - b) / 6) + (d / 2)) / d;

@@ -395,6 +396,11 @@ if (r === max) {

hexToRGB: function (hexStr) {
var cache = colorCache(hexStr);
if (cache.rgb) return cache.rgb;
var h = ColorHelper.strToHexColor(hexStr);
if (!h) throw 'Unknown color "' + hexStr + '"';
var h,
cache = colorCache(hexStr);
if (cache.rgb) {
return cache.rgb;
}
h = ColorHelper.strToHexColor(hexStr);
if (!h) {
throw 'Unknown color "' + hexStr + '"';
}
cache.rgb = [parseInt(h.substr(1, 2), 16), parseInt(h.substr(3, 2), 16), parseInt(h.substr(5, 2), 16)];

@@ -405,4 +411,4 @@ return cache.rgb;

lighten: function (color, percent) {
var hsl = ColorHelper.rgbToHSL(color);
var newHSL = [hsl[0], hsl[1], Math.min(100, hsl[2] + percent)];
var hsl = ColorHelper.rgbToHSL(color),
newHSL = [hsl[0], hsl[1], Math.min(100, hsl[2] + percent)];
return ColorHelper.hslToHexColor(newHSL);

@@ -412,4 +418,4 @@ },

darken: function (color, percent) {
var hsl = ColorHelper.rgbToHSL(color);
var newHSL = [hsl[0], hsl[1], Math.max(0, hsl[2] - percent)];
var hsl = ColorHelper.rgbToHSL(color),
newHSL = [hsl[0], hsl[1], Math.max(0, hsl[2] - percent)];
return ColorHelper.hslToHexColor(newHSL);

@@ -423,4 +429,4 @@ },

saturate: function (color, percent) {
var hsl = ColorHelper.rgbToHSL(color);
var newHSL = [hsl[0], Math.min(100, Math.max(0, hsl[1] + percent)), hsl[2]];
var hsl = ColorHelper.rgbToHSL(color),
newHSL = [hsl[0], Math.min(100, Math.max(0, hsl[1] + percent)), hsl[2]];
return ColorHelper.hslToHexColor(newHSL);

@@ -427,0 +433,0 @@ },

@@ -126,3 +126,3 @@ QUnit.module('ColorFactory');

ColorFactory.sequential('#c4b3d8', 7),
["#c3b2d7", "#ac93c8", "#9475b8", "#7d57a8", "#66478a", "#50376c", "#39284d"]
['#c3b2d7', '#ac93c8', '#9475b8', '#7d57a8', '#66478a', '#50376c', '#39284d']
);

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

/* Utilities */
var renderId = 0;
function renderColors(colors, target, label) {

@@ -8,6 +7,3 @@ target = target || 'body';

var i,
$swatches = $('<div>', {
'class': 'test-colorFactory-swatches',
'id': 'test-colorFactory-swatches-' + (++renderId)
});
$swatches = $('<div>').addClass('test-colorFactory-swatches');

@@ -22,7 +18,3 @@ for (i = 0; i < colors.length; i += 1) {

$swatches,
$('<div>', {
'class': 'test-colorFactory-label',
'for': 'test-colorFactory-swatches-' + renderId,
'text': label || ''
})
$('<div>').text(label).addClass('test-colorFactory-label')
).appendTo(target);

@@ -37,3 +29,3 @@ });

this.renderColors = function (colors, label) {
renderColors(colors, '#' + QUnit.config.current.id, label);
renderColors(colors, '#qunit-test-output-' + QUnit.config.current.testId, label);
};

@@ -127,10 +119,11 @@ this.renderColors(actualColors, 'actual');

var expectedHsl = ColorHelper.rgbToHSL(expected);
var actualHsl = ColorHelper.rgbToHSL(actual);
var diff = [];
for (var d in actualHsl) {
var d,
expectedHsl = ColorHelper.rgbToHSL(expected),
actualHsl = ColorHelper.rgbToHSL(actual),
diffTotal = 0,
diff = [];
for (d in actualHsl) {
diff.push(Math.abs(expectedHsl[d] - actualHsl[d]));
}
var diffTotal = 0;
for (d in diff) {

@@ -137,0 +130,0 @@ diffTotal += diff[d];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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