Comparing version 0.18.0 to 0.18.1
{ | ||
"name": "rework", | ||
"version": "0.18.0", | ||
"version": "0.18.1", | ||
"description": "CSS manipulations built on CSSOM", | ||
@@ -12,3 +12,4 @@ "keywords": ["css", "manipulation", "preprocess", "transform"], | ||
"component/path": "1.0.0", | ||
"jonathanong/rework-inherit": "0.1.5" | ||
"jonathanong/rework-inherit": "0.1.5", | ||
"jankuca/hsb2rgb": "1.0.2" | ||
}, | ||
@@ -15,0 +16,0 @@ "scripts": [ |
0.18.1 / 2013-09-03 | ||
================== | ||
* extract hsb2rgb() as a separate npm module | ||
0.18.0 / 2013-09-02 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -7,2 +7,3 @@ | ||
var parse = require('color-parser'); | ||
var hsb2rgb = require('hsb2rgb'); | ||
var functions = require('./function'); | ||
@@ -73,41 +74,1 @@ | ||
}; | ||
/** | ||
* HSB conversion. | ||
*/ | ||
function hsb2rgb(hue, saturation, value) { | ||
hue = (parseInt(hue, 10) || 0) % 360; | ||
saturation = /%/.test(saturation) | ||
? parseInt(saturation, 10) / 100 | ||
: parseFloat(saturation, 10); | ||
value = /%/.test(value) | ||
? parseInt(value, 10) / 100 | ||
: parseFloat(value, 10); | ||
var rgb; | ||
if (0 == saturation) return [value, value, value]; | ||
var side = hue / 60; | ||
var chroma = value * saturation; | ||
var x = chroma * (1 - Math.abs(side % 2 - 1)); | ||
var match = value - chroma; | ||
switch (Math.floor(side)) { | ||
case 0: rgb = [chroma, x, 0]; break; | ||
case 1: rgb = [x, chroma, 0]; break; | ||
case 2: rgb = [0, chroma, x]; break; | ||
case 3: rgb = [0, x, chroma]; break; | ||
case 4: rgb = [x, 0, chroma]; break; | ||
case 5: rgb = [chroma, 0, x]; break; | ||
default: rgb = [0, 0, 0]; | ||
} | ||
rgb[0] = Math.round(255 * (rgb[0] + match)); | ||
rgb[1] = Math.round(255 * (rgb[1] + match)); | ||
rgb[2] = Math.round(255 * (rgb[2] + match)); | ||
return rgb; | ||
} |
{ | ||
"name": "rework", | ||
"version": "0.18.0", | ||
"version": "0.18.1", | ||
"description": "CSS manipulations built on CSSOM", | ||
@@ -15,2 +15,3 @@ "keywords": ["css", "manipulation", "preprocess", "transform"], | ||
"color-parser": "0.1.0", | ||
"hsb2rgb": "1.0.2", | ||
"mime": "1.2.9", | ||
@@ -17,0 +18,0 @@ "debug": "*", |
42699
8
936
+ Addedhsb2rgb@1.0.2
+ Addedhsb2rgb@1.0.2(transitive)