From e812e1665665d74bf29c5f2495f8a7e6bc1cec5c Mon Sep 17 00:00:00 2001 From: Lucas Green Date: Wed, 9 May 2012 01:08:26 -0700 Subject: [PATCH] Added: red() green() and blue() functions, with tests. --- lib/less/functions.js | 9 +++++++++ test/css/functions.css | 3 +++ test/less/functions.less | 3 +++ 3 files changed, 15 insertions(+) diff --git a/lib/less/functions.js b/lib/less/functions.js index 8e95a065..6e2e774f 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -41,6 +41,15 @@ tree.functions = { lightness: function (color) { return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%'); }, + red: function (color) { + return new(tree.Dimension)(color.rgb[0]); + }, + green: function (color) { + return new(tree.Dimension)(color.rgb[1]); + }, + blue: function (color) { + return new(tree.Dimension)(color.rgb[2]); + }, alpha: function (color) { return new(tree.Dimension)(color.toHSL().a); }, diff --git a/test/css/functions.css b/test/css/functions.css index 3b16647a..47731c27 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -44,6 +44,9 @@ hue: 98; saturation: 12%; lightness: 95%; + red: 255; + green: 255; + blue: 255; rounded: 11; roundedpx: 3px; percentage: 20%; diff --git a/test/less/functions.less b/test/less/functions.less index 638b79e1..94ac71ef 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -48,6 +48,9 @@ hue: hue(hsl(98, 12%, 95%)); saturation: saturation(hsl(98, 12%, 95%)); lightness: lightness(hsl(98, 12%, 95%)); + red: red(#f00); + green: green(#0f0); + blue: blue(#00f); rounded: round(@r/3); roundedpx: round(10px / 3); percentage: percentage(10px / 50);