Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/chroma-js/src/conversions/hsv2rgb.coffee')
-rw-r--r--node_modules/chroma-js/src/conversions/hsv2rgb.coffee27
1 files changed, 27 insertions, 0 deletions
diff --git a/node_modules/chroma-js/src/conversions/hsv2rgb.coffee b/node_modules/chroma-js/src/conversions/hsv2rgb.coffee
new file mode 100644
index 0000000000..7d71c6c35c
--- /dev/null
+++ b/node_modules/chroma-js/src/conversions/hsv2rgb.coffee
@@ -0,0 +1,27 @@
+
+hsv2rgb = () ->
+ [h,s,v] = unpack arguments
+ v *= 255
+ if s is 0
+ r = g = b = v
+ else
+ h = 0 if h is 360
+ h -= 360 if h > 360
+ h += 360 if h < 0
+ h /= 60
+ i = Math.floor h
+ f = h - i
+ p = v * (1 - s)
+ q = v * (1 - s * f)
+ t = v * (1 - s * (1 - f))
+ switch i
+ when 0 then [r,g,b] = [v, t, p]
+ when 1 then [r,g,b] = [q, v, p]
+ when 2 then [r,g,b] = [p, v, t]
+ when 3 then [r,g,b] = [p, q, v]
+ when 4 then [r,g,b] = [t, p, v]
+ when 5 then [r,g,b] = [v, p, q]
+ r = Math.round r
+ g = Math.round g
+ b = Math.round b
+ [r, g, b]