From f8bee84fdfeb8ff27465137159a437408ae36d37 Mon Sep 17 00:00:00 2001 From: Synchro Date: Wed, 12 Sep 2012 18:49:21 +0200 Subject: [PATCH] Implement tint and shade functions --- lib/less/functions.js | 6 ++++++ test/css/functions.css | 6 ++++++ test/less/functions.less | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/lib/less/functions.js b/lib/less/functions.js index 7e199938..2e0cc513 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -304,6 +304,12 @@ tree.functions = { var g = 255 - Math.abs(255 - color2.rgb[1] - color1.rgb[1]); var b = 255 - Math.abs(255 - color2.rgb[2] - color1.rgb[2]); return this.rgb(r, g, b); + }, + tint: function(color, amount) { + return this.mix(this.rgb(255,255,255), color, amount); + }, + shade: function(color, amount) { + return this.mix(this.rgb(0, 0, 0), color, amount); } }; diff --git a/test/css/functions.css b/test/css/functions.css index 933370b1..a1413ef8 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -54,6 +54,12 @@ roundedpx-three: 3.333px; percentage: 20%; color: #ff0011; + tint: #898989; + tint-full: #ffffff; + tint-percent: #898989; + shade: #686868; + shade-full: #000000; + shade-percent: #686868; mix: #ff3300; mix-0: #ffff00; mix-100: #ff0000; diff --git a/test/less/functions.less b/test/less/functions.less index 0eb3bad4..6afed382 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -59,6 +59,12 @@ roundedpx-three: round(10px / 3, 3); percentage: percentage(10px / 50); color: color("#ff0011"); + tint: tint(#777777, 13); + tint-full: tint(#777777, 100); + tint-percent: tint(#777777, 13%); + shade: shade(#777777, 13); + shade-full: shade(#777777, 100); + shade-percent: shade(#777777, 13%); mix: mix(#ff0000, #ffff00, 80); mix-0: mix(#ff0000, #ffff00, 0);