[Pkg-javascript-commits] [less.js] 84/88: Introduce luminance function.
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:29 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 e7389a0e7a0a47c3af1905256fe2f2e2cdee34ae
Author: Roel van Duijnhoven <roel.duijnhoven at gmail.com>
Date: Thu Feb 27 08:45:24 2014 +0100
Introduce luminance function.
The behaviour of this function is identical to luma prior to LESS 1.7.
---
lib/less/functions.js | 8 ++++++++
test/css/functions.css | 6 +++++-
test/less/functions.less | 6 +++++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/less/functions.js b/lib/less/functions.js
index 2c269a9..eb7309c 100644
--- a/lib/less/functions.js
+++ b/lib/less/functions.js
@@ -95,6 +95,14 @@ tree.functions = {
luma: function (color) {
return new(tree.Dimension)(Math.round(color.luma() * color.alpha * 100), '%');
},
+ luminance: function (color) {
+ var luminance =
+ (0.2126 * color.rgb[0] / 255)
+ + (0.7152 * color.rgb[1] / 255)
+ + (0.0722 * color.rgb[2] / 255);
+
+ return new(tree.Dimension)(Math.round(luminance * color.alpha * 100), '%');
+ },
saturate: function (color, amount) {
// filter: saturate(3.2);
// should be kept as is, so check for color
diff --git a/test/css/functions.css b/test/css/functions.css
index 6541f1b..1220bd0 100644
--- a/test/css/functions.css
+++ b/test/css/functions.css
@@ -25,7 +25,11 @@
luma-yellow: 93%;
luma-cyan: 79%;
luma-differs-from-luminance: 24%;
- luma-white-alpha: 50%;
+ luminance-white: 100%;
+ luminance-black: 0%;
+ luminance-black-alpha: 0%;
+ luminance-red: 21%;
+ luminance-differs-from-luma: 36%;
contrast-filter: contrast(30%);
saturate-filter: saturate(5%);
contrast-white: #000000;
diff --git a/test/less/functions.less b/test/less/functions.less
index de74ba8..8a45ef9 100644
--- a/test/less/functions.less
+++ b/test/less/functions.less
@@ -29,7 +29,11 @@
luma-yellow: luma(#ffff00);
luma-cyan: luma(#00ffff);
luma-differs-from-luminance: luma(#ff3600);
- luma-white-alpha: luma(rgba(255,255,255,0.5));
+ luminance-white: luma(#fff);
+ luminance-black: luma(#000);
+ luminance-black-alpha: luma(rgba(0,0,0,0.5));
+ luminance-red: luma(#ff0000);
+ luminance-differs-from-luma: luminance(#ff3600);
contrast-filter: contrast(30%);
saturate-filter: saturate(5%);
contrast-white: contrast(#fff);
--
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