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/rgb2hsl.coffee')
-rw-r--r--node_modules/chroma-js/src/conversions/rgb2hsl.coffee26
1 files changed, 26 insertions, 0 deletions
diff --git a/node_modules/chroma-js/src/conversions/rgb2hsl.coffee b/node_modules/chroma-js/src/conversions/rgb2hsl.coffee
new file mode 100644
index 0000000000..2b1cfafd71
--- /dev/null
+++ b/node_modules/chroma-js/src/conversions/rgb2hsl.coffee
@@ -0,0 +1,26 @@
+
+rgb2hsl = (r,g,b) ->
+ if r != undefined and r.length >= 3
+ [r,g,b] = r
+ r /= 255
+ g /= 255
+ b /= 255
+
+ min = Math.min(r, g, b)
+ max = Math.max(r, g, b)
+
+ l = (max + min) / 2
+
+ if max == min
+ s = 0
+ h = Number.NaN
+ else
+ s = if l < 0.5 then (max - min) / (max + min) else (max - min) / (2 - max - min)
+
+ if r == max then h = (g - b) / (max - min)
+ else if (g == max) then h = 2 + (b - r) / (max - min)
+ else if (b == max) then h = 4 + (r - g) / (max - min)
+
+ h *= 60;
+ h += 360 if h < 0
+ [h,s,l]