mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Let luma follow spec
The `luma` function found in LESS is not implemented as defined in the specification (http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef).
This commit is contained in:
@@ -28,7 +28,17 @@ var transparentKeyword = "transparent";
|
||||
tree.Color.prototype = {
|
||||
type: "Color",
|
||||
eval: function () { return this; },
|
||||
luma: function () { return (0.2126 * this.rgb[0] / 255) + (0.7152 * this.rgb[1] / 255) + (0.0722 * this.rgb[2] / 255); },
|
||||
luma: function () {
|
||||
var r = this.rgb[0] / 255,
|
||||
g = this.rgb[1] / 255,
|
||||
b = this.rgb[2] / 255;
|
||||
|
||||
r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
|
||||
g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
|
||||
b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
|
||||
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
},
|
||||
|
||||
genCSS: function (env, output) {
|
||||
output.add(this.toCSS(env));
|
||||
|
||||
Reference in New Issue
Block a user