Commit e58c20f3 authored by David Schnur's avatar David Schnur

Merge branch 'master' of https://github.com/k-nut/flot into code-cleanup

parents 8e12ecd7 672b9b88
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
return value < min ? min: (value > max ? max: value); return value < min ? min: (value > max ? max: value);
} }
o.r = clamp(0, parseInt(o.r), 255); o.r = clamp(0, parseInt(o.r, 10), 255);
o.g = clamp(0, parseInt(o.g), 255); o.g = clamp(0, parseInt(o.g, 10), 255);
o.b = clamp(0, parseInt(o.b), 255); o.b = clamp(0, parseInt(o.b, 10), 255);
o.a = clamp(0, o.a, 1); o.a = clamp(0, o.a, 1);
return o; return o;
}; };
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
}; };
return o.normalize(); return o.normalize();
} };
// extract CSS color property from element, going up in the DOM // extract CSS color property from element, going up in the DOM
// if it's "transparent" // if it's "transparent"
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
c = elem.css(css).toLowerCase(); c = elem.css(css).toLowerCase();
// keep going until we find an element that has color, or // keep going until we find an element that has color, or
// we hit the body // we hit the body
if (c != '' && c != 'transparent') if (c !== '' && c != 'transparent')
break; break;
elem = elem.parent(); elem = elem.parent();
} while (!$.nodeName(elem.get(0), "body")); } while (!$.nodeName(elem.get(0), "body"));
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
c = "transparent"; c = "transparent";
return $.color.parse(c); return $.color.parse(c);
} };
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"), // parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
// returns color object, if parsing failed, you get black (0, 0, // returns color object, if parsing failed, you get black (0, 0,
...@@ -97,27 +97,33 @@ ...@@ -97,27 +97,33 @@
var res, m = $.color.make; var res, m = $.color.make;
// Look for rgb(num,num,num) // Look for rgb(num,num,num)
if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str)) res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str);
if (res)
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10)); return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10));
// Look for rgba(num,num,num,num) // Look for rgba(num,num,num,num)
if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str);
if (res)
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4])); return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4]));
// Look for rgb(num%,num%,num%) // Look for rgb(num%,num%,num%)
if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str)) res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str);
if (res)
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55); return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55);
// Look for rgba(num%,num%,num%,num) // Look for rgba(num%,num%,num%,num)
if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str);
if (res)
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4])); return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4]));
// Look for #a0b1c2 // Look for #a0b1c2
if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str)) res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str);
if (res)
return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16)); return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16));
// Look for #fff // Look for #fff
if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str)) res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str);
if (res)
return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16)); return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16));
// Otherwise, we're most likely dealing with a named color // Otherwise, we're most likely dealing with a named color
...@@ -129,7 +135,7 @@ ...@@ -129,7 +135,7 @@
res = lookupColors[name] || [0, 0, 0]; res = lookupColors[name] || [0, 0, 0];
return m(res[0], res[1], res[2]); return m(res[0], res[1], res[2]);
} }
} };
var lookupColors = { var lookupColors = {
aqua:[0,255,255], aqua:[0,255,255],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment