Comparing version 0.7.1 to 0.7.2
17
color.js
@@ -5,7 +5,6 @@ /* MIT license */ | ||
module.exports = function(cssString) { | ||
return new Color(cssString); | ||
}; | ||
var Color = function(cssString) { | ||
if (cssString instanceof Color) return cssString; | ||
if (! (this instanceof Color)) return new Color(cssString); | ||
var Color = function(cssString) { | ||
this.values = { | ||
@@ -33,3 +32,3 @@ rgb: [0, 0, 0], | ||
else { | ||
throw new Error("Unable to parse color from string " + cssString); | ||
throw new Error("Unable to parse color from string \"" + cssString + "\""); | ||
} | ||
@@ -179,2 +178,6 @@ } | ||
rgbNumber: function() { | ||
return (this.values.rgb[0] << 16) | (this.values.rgb[1] << 8) | this.values.rgb[2]; | ||
}, | ||
luminosity: function() { | ||
@@ -423,2 +426,3 @@ // http://www.w3.org/TR/WCAG20/#relativeluminancedef | ||
Color.prototype.setChannel = function(space, index, val) { | ||
console.log("setting channel", space, index, val); | ||
if (val === undefined) { | ||
@@ -429,2 +433,3 @@ // color.red() | ||
// color.red(100) | ||
console.log(this.values[space]); | ||
this.values[space][index] = val; | ||
@@ -434,1 +439,3 @@ this.setValues(space, this.values[space]); | ||
} | ||
module.exports = Color; |
@@ -6,5 +6,4 @@ { | ||
"author": "Heather Arthur <fayearthur@gmail.com>", | ||
"repository": "harthur/color", | ||
"repo": "harthur/color", | ||
"main": "color.js", | ||
"scripts": ["color.js"], | ||
"dependencies": { | ||
@@ -14,2 +13,3 @@ "harthur/color-convert": "*", | ||
}, | ||
"scripts": ["color.js"], | ||
"keywords": [ | ||
@@ -16,0 +16,0 @@ "color", |
{ | ||
"name": "color", | ||
"description": "Color conversion and manipulation with CSS string support", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"author": "Heather Arthur <fayearthur@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
14
test.js
var Color = require("./color"); | ||
console.log(Color([255,255,255]).alpha(0).hslaString()); // "hsla(0, 0%, 0%, 1)" | ||
var color = Color({ h : 0, s : 0, v : 100 }); | ||
console.log(color.hslString()); | ||
// color.hexString(); // #FFFFFF | ||
// color.hue(100); | ||
// color.hexString(); // #NANNANNAN | ||
//var color = Color("#7743CE").rgb(); | ||
console.log(color.hexString()); |
var Color = require("../color"), | ||
assert = require("assert"); | ||
// Color() instance | ||
assert.equal(new Color("red").red(), 255); | ||
assert.ok((new Color) instanceof Color); | ||
// Color() argument | ||
@@ -112,2 +117,5 @@ assert.deepEqual(Color("#0A1E19").rgb(), {r: 10, g: 30, b: 25}); | ||
// Number getters | ||
assert.equal(Color("rgb(10, 30, 25)").rgbNumber(), 0xA1E19) | ||
// luminosity, etc. | ||
@@ -114,0 +122,0 @@ assert.equal(Color("white").luminosity(), 1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126146
17
2772
9
1