diff options
Diffstat (limited to 'node_modules/color-convert')
-rw-r--r-- | node_modules/color-convert/conversions.js | 65 | ||||
-rw-r--r-- | node_modules/color-convert/package.json | 8 |
2 files changed, 40 insertions, 33 deletions
diff --git a/node_modules/color-convert/conversions.js b/node_modules/color-convert/conversions.js index 19ca4a9bf..32172007e 100644 --- a/node_modules/color-convert/conversions.js +++ b/node_modules/color-convert/conversions.js @@ -95,41 +95,48 @@ convert.rgb.hsl = function (rgb) { }; convert.rgb.hsv = function (rgb) { - var r = rgb[0]; - var g = rgb[1]; - var b = rgb[2]; - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var delta = max - min; + var rdif; + var gdif; + var bdif; var h; var s; - var v; - if (max === 0) { - s = 0; + var r = rgb[0] / 255; + var g = rgb[1] / 255; + var b = rgb[2] / 255; + var v = Math.max(r, g, b); + var diff = v - Math.min(r, g, b); + var diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; + + if (diff === 0) { + h = s = 0; } else { - s = (delta / max * 1000) / 10; - } - - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } - - h = Math.min(h * 60, 360); - - if (h < 0) { - h += 360; + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); + + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } } - v = ((max / 255) * 1000) / 10; - - return [h, s, v]; + return [ + h * 360, + s * 100, + v * 100 + ]; }; convert.rgb.hwb = function (rgb) { diff --git a/node_modules/color-convert/package.json b/node_modules/color-convert/package.json index f1a3edc61..dfbc47140 100644 --- a/node_modules/color-convert/package.json +++ b/node_modules/color-convert/package.json @@ -1,7 +1,7 @@ { "name": "color-convert", "description": "Plain color conversion functions", - "version": "1.9.1", + "version": "1.9.3", "author": "Heather Arthur <fayearthur@gmail.com>", "license": "MIT", "repository": "Qix-/color-convert", @@ -37,10 +37,10 @@ } }, "devDependencies": { - "chalk": "^1.1.1", - "xo": "^0.11.2" + "chalk": "1.1.1", + "xo": "0.11.2" }, "dependencies": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } } |