on master help sign in
cosmetic: fix indentation
commit20bbb71359ea91c57adcb52253dc4bc1127a4ab1 authorEvan Czaplicki <info@elm-lang.org> dateThu 10 Oct 2013, 12:14 (13 years ago) parent15aec26
1 file changed+54−54
libraries/Native/Color.js+54−54
libraries/Native/Color.js+54−54
@@ -1,69 +1,69 @@
11Elm.Native.Color = {};
22Elm.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;
3+ elm.Native = elm.Native || {};
4+ elm.Native.Color = elm.Native.Color || {};
5+ if (elm.Native.Color.values) return elm.Native.Color.values;
66
7− var Utils = Elm.Native.Utils.make(elm);
7+ var Utils = Elm.Native.Utils.make(elm);
88
9− function complement(rgb) {
10− var hsv = toHSV(rgb);
11− hsv.hue = (hsv.hue + 180) % 360;
12− return toRGB(hsv);
13− }
9+ function complement(rgb) {
10+ var hsv = toHSV(rgb);
11+ hsv.hue = (hsv.hue + 180) % 360;
12+ return toRGB(hsv);
13+ }
1414
15− function hsva(h,s,v,a) {
16− var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
17− var clr = toRGB({hue:degree, saturation:s, value:v});
18− clr._3 = a;
19− return clr;
20− }
15+ function hsva(h,s,v,a) {
16+ var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
17+ var clr = toRGB({hue:degree, saturation:s, value:v});
18+ clr._3 = a;
19+ return clr;
20+ }
2121
22− function hsv(h,s,v) {
23− var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
24− return toRGB({hue:degree, saturation:s, value:v});
25− }
22+ function hsv(h,s,v) {
23+ var degree = A2(Utils.mod, h * 180 / Math.PI, 360);
24+ return toRGB({hue:degree, saturation:s, value:v});
25+ }
2626
27− function toHSV(rgb) {
28− var hsv = {};
29− var r = rgb._0 / 255.0, g = rgb._1 / 255.0, b = rgb._2 / 255.0;
30− var M = Math.max(r,g,b);
31− var m = Math.min(r,g,b);
32− var c = M - m;
27+ function toHSV(rgb) {
28+ var hsv = {};
29+ var r = rgb._0 / 255.0, g = rgb._1 / 255.0, b = rgb._2 / 255.0;
30+ var M = Math.max(r,g,b);
31+ var m = Math.min(r,g,b);
32+ var c = M - m;
3333
34− var h = 0;
35− if (c === 0) { h = 0; }
36− else if (M === r) { h = ((g - b) / c) % 6; }
37− else if (M === g) { h = ((b - r) / c) + 2; }
38− else if (M === b) { h = ((r - g) / c) + 4; }
39− h *= 60;
34+ var h = 0;
35+ if (c === 0) { h = 0; }
36+ else if (M === r) { h = ((g - b) / c) % 6; }
37+ else if (M === g) { h = ((b - r) / c) + 2; }
38+ else if (M === b) { h = ((r - g) / c) + 4; }
39+ h *= 60;
4040
41− return { value : M, hue : h, saturation : (M === 0 ? 0 : c / M) };
42− }
41+ return { value : M, hue : h, saturation : (M === 0 ? 0 : c / M) };
42+ }
4343
44− function between(lo,hi,x) { return lo <= x && x < hi; }
45− function norm(n) { return Math.round(n*255); }
44+ function between(lo,hi,x) { return lo <= x && x < hi; }
45+ function norm(n) { return Math.round(n*255); }
4646
47− function toRGB(hsv) {
48− var c = hsv.value * hsv.saturation;
49− var hue = hsv.hue / 60;
50− var x = c * (1 - Math.abs((hue % 2) - 1));
51− var r = 0, g = 0, b = 0;
52− if (between(0,1,hue)) { r = c; g = x; b = 0; }
53− else if (between(1,2,hue)) { r = x; g = c; b = 0; }
54− else if (between(2,3,hue)) { r = 0; g = c; b = x; }
55− else if (between(3,4,hue)) { r = 0; g = x; b = c; }
56− else if (between(4,5,hue)) { r = x; g = 0; b = c; }
57− else if (between(5,6,hue)) { r = c; g = 0; b = x; }
47+ function toRGB(hsv) {
48+ var c = hsv.value * hsv.saturation;
49+ var hue = hsv.hue / 60;
50+ var x = c * (1 - Math.abs((hue % 2) - 1));
51+ var r = 0, g = 0, b = 0;
52+ if (between(0,1,hue)) { r = c; g = x; b = 0; }
53+ else if (between(1,2,hue)) { r = x; g = c; b = 0; }
54+ else if (between(2,3,hue)) { r = 0; g = c; b = x; }
55+ else if (between(3,4,hue)) { r = 0; g = x; b = c; }
56+ else if (between(4,5,hue)) { r = x; g = 0; b = c; }
57+ else if (between(5,6,hue)) { r = c; g = 0; b = x; }
5858
59− var m = hsv.value - c;
60− return { ctor:"Color", _0:norm(r+m), _1:norm(g+m), _2:norm(b+m), _3:1 };
61− }
59+ var m = hsv.value - c;
60+ return { ctor:"Color", _0:norm(r+m), _1:norm(g+m), _2:norm(b+m), _3:1 };
61+ }
6262
63− return elm.Native.Color.values = {
64− hsva:F4(hsva),
65− hsv:F3(hsv),
66− complement:complement
67− };
63+ return elm.Native.Color.values = {
64+ hsva:F4(hsva),
65+ hsv:F3(hsv),
66+ complement:complement
67+ };
6868
6969};