[Pkg-javascript-commits] [less.js] 66/88: Let `luma` follow spec

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:22:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.0
in repository less.js.

commit ea1822385a01711b650894cdd923f5871e497d3a
Author: Roel van Duijnhoven <roel.duijnhoven at gmail.com>
Date:   Thu Feb 20 16:19:19 2014 +0100

    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).
---
 lib/less/tree/color.js | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/less/tree/color.js b/lib/less/tree/color.js
index 8ea3fe0..eac71f7 100644
--- a/lib/less/tree/color.js
+++ b/lib/less/tree/color.js
@@ -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));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list