3Elm.Native.Color = function(elm) {
6 elm.Native = elm.Native || {};
7 if (elm.Native.Color) return elm.Native.Color;
9 var Utils = Elm.Native.Utils(elm);
11 function complement(rgb) {
13 hsv.hue = (hsv.hue + 180) % 360;
17 function hsva(h,s,v,a) {
18 var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
19 var clr = toRGB({hue:degree, saturation:s, value:v});
25 var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
26 return toRGB({hue:degree, saturation:s, value:v});
31 var r = rgb._0 / 255.0, g = rgb._1 / 255.0, b = rgb._2 / 255.0;
32 var M = Math.max(r,g,b);
33 var m = Math.min(r,g,b);
37 if (c === 0) { h = 0; }
38 else if (M === r) { h = ((g - b) / c) % 6; }
39 else if (M === g) { h = ((b - r) / c) + 2; }
40 else if (M === b) { h = ((r - g) / c) + 4; }
43 return { value : M, hue : h, saturation : (M === 0 ? 0 : c / M) };
46 function between(lo,hi,x) { return lo <= x && x < hi; }
47 function norm(n) { return Math.round(n*255); }
50 var c = hsv.value * hsv.saturation;
51 var hue = hsv.hue / 60;
52 var x = c * (1 - Math.abs((hue % 2) - 1));
53 var r = 0, g = 0, b = 0;
54 if (between(0,1,hue)) { r = c; g = x; b = 0; }
55 else if (between(1,2,hue)) { r = x; g = c; b = 0; }
56 else if (between(2,3,hue)) { r = 0; g = c; b = x; }
57 else if (between(3,4,hue)) { r = 0; g = x; b = c; }
58 else if (between(4,5,hue)) { r = x; g = 0; b = c; }
59 else if (between(5,6,hue)) { r = c; g = 0; b = x; }
61 var m = hsv.value - c;
62 return { ctor:"Color", _0:norm(r+m), _1:norm(g+m), _2:norm(b+m), _3:1 };
65 return elm.Native.Color = {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list