3Elm.Native.Graphics.Color = function(elm) {
6 elm.Native = elm.Native || {};
7 elm.Native.Graphics = elm.Native.Graphics || {};
8 if (elm.Native.Graphics.Color) return elm.Native.Graphics.Color;
10 function complement(rgb) {
12 hsv.hue = (hsv.hue + 180) % 360;
16 function hsva(h,s,v,a) {
17 var clr = toRGB({hue:h, saturation:s, value:v});
22 function hsv(h,s,v) { return toRGB({hue:h, saturation:s, value:v}); }
26 var r = rgb._0 / 255.0, g = rgb._1 / 255.0, b = rgb._2 / 255.0;
27 var M = Math.max(r,g,b);
28 var m = Math.min(r,g,b);
32 if (c === 0) { h = 0; }
33 else if (M === r) { h = ((g - b) / c) % 6; }
34 else if (M === g) { h = ((b - r) / c) + 2; }
35 else if (M === b) { h = ((r - g) / c) + 4; }
38 return { value : M, hue : h, saturation : (M === 0 ? 0 : c / M) };
41 function between(lo,hi,x) { return lo <= x && x < hi; }
42 function norm(n) { return Math.round(n*255); }
45 var c = hsv.value * hsv.saturation;
46 var hue = hsv.hue / 60;
47 var x = c * (1 - Math.abs((hue % 2) - 1));
48 var r = 0, g = 0, b = 0;
49 if (between(0,1,hue)) { r = c; g = x; b = 0; }
50 else if (between(1,2,hue)) { r = x; g = c; b = 0; }
51 else if (between(2,3,hue)) { r = 0; g = c; b = x; }
52 else if (between(3,4,hue)) { r = 0; g = x; b = c; }
53 else if (between(4,5,hue)) { r = x; g = 0; b = c; }
54 else if (between(5,6,hue)) { r = c; g = 0; b = x; }
56 var m = hsv.value - c;
57 return { ctor:"Color", _0:norm(r+m), _1:norm(g+m), _2:norm(b+m), _3:1 };
60 return elm.Native.Graphics.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