From 78385525743049340fb59f55d83a5f73c1b67b16 Mon Sep 17 00:00:00 2001 From: Josh Yudaken Date: Mon, 23 Jan 2012 18:21:07 +0200 Subject: [PATCH] implement luma() function call --- lib/less/functions.js | 5 +++++ test/css/functions.css | 1 + test/less/functions.less | 1 + 3 files changed, 7 insertions(+) diff --git a/lib/less/functions.js b/lib/less/functions.js index 6eb34bac8..1a10f8ca6 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -44,6 +44,11 @@ tree.functions = { alpha: function (color) { return new(tree.Dimension)(color.toHSL().a); }, + luma: function (color) { + return new(tree.Dimension)(Math.round(color.rgb[0]*30/255 + + color.rgb[1]*59/255 + + color.rgb[2]*11/255), '%'); + }, saturate: function (color, amount) { var hsl = color.toHSL(); diff --git a/test/css/functions.css b/test/css/functions.css index 823281457..0f625a2b0 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -22,6 +22,7 @@ hue: 98; saturation: 12%; lightness: 95%; + luma: 23%; rounded: 11; roundedpx: 3px; percentage: 20%; diff --git a/test/less/functions.less b/test/less/functions.less index 535d2efde..bd2699553 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -26,6 +26,7 @@ hue: hue(hsl(98, 12%, 95%)); saturation: saturation(hsl(98, 12%, 95%)); lightness: lightness(hsl(98, 12%, 95%)); + luma: luma(rgb(180, 0, 50)); rounded: round(@r/3); roundedpx: round(10px / 3); percentage: percentage(10px / 50);