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/hsl2rgb.coffee')
-rw-r--r--node_modules/chroma-js/src/conversions/hsl2rgb.coffee28
1 files changed, 28 insertions, 0 deletions
diff --git a/node_modules/chroma-js/src/conversions/hsl2rgb.coffee b/node_modules/chroma-js/src/conversions/hsl2rgb.coffee
new file mode 100644
index 0000000000..f9c021f478
--- /dev/null
+++ b/node_modules/chroma-js/src/conversions/hsl2rgb.coffee
@@ -0,0 +1,28 @@
+
+hsl2rgb = () ->
+ [h,s,l] = unpack arguments
+ if s == 0
+ r = g = b = l*255
+ else
+ t3 = [0,0,0]
+ c = [0,0,0]
+ t2 = if l < 0.5 then l * (1+s) else l+s-l*s
+ t1 = 2 * l - t2
+ h /= 360
+ t3[0] = h + 1/3
+ t3[1] = h
+ t3[2] = h - 1/3
+ for i in [0..2]
+ t3[i] += 1 if t3[i] < 0
+ t3[i] -= 1 if t3[i] > 1
+ if 6 * t3[i] < 1
+ c[i] = t1 + (t2 - t1) * 6 * t3[i]
+ else if 2 * t3[i] < 1
+ c[i] = t2
+ else if 3 * t3[i] < 2
+ c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6
+ else
+ c[i] = t1
+ [r,g,b] = [Math.round(c[0]*255),Math.round(c[1]*255),Math.round(c[2]*255)]
+ [r,g,b]
+