on 14ef71a help sign in
elk/libraries/Native/Color.js
32 lines 880 B history raw
1Elm.Native.Color = {};
2Elm.Native.Color.make = function(elm) {
3 elm.Native = elm.Native || {};
4 elm.Native.Color = elm.Native.Color || {};
5 if (elm.Native.Color.values) return elm.Native.Color.values;
7 var Utils = Elm.Native.Utils.make(elm);
9 function toCss(c) {
10 var format = '';
11 var colors = '';
12 if (c.ctor === 'RGBA') {
13 format = 'rgb';
14 colors = c._0 + ', ' + c._1 + ', ' + c._2;
15 } else {
16 format = 'hsl';
17 colors = (c._0 * 180 / Math.PI) + ', ' +
18 (c._1 * 100) + '%, ' +
19 (c._2 * 100) + '%';
20 }
21 if (c._3 === 1) {
22 return format + '(' + colors + ')';
23 } else {
24 return format + 'a(' + colors + ', ' + c._3 + ')';
25 }
26 }
28 return elm.Native.Color.values = {
29 toCss:toCss
30 };
32};