From cdcd77b68b78115e3e90ca786168393512af17a2 Mon Sep 17 00:00:00 2001 From: Alex Kaye Date: Sat, 21 Dec 2013 17:51:45 +0000 Subject: [PATCH] contrast() now accepts percentage threshold Fixes leafo/lessphp#501 --- lessc.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index 1571fc23..416eae04 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -1242,12 +1242,18 @@ protected function lib_contrast($args) { $darkColor = array('color', 0, 0, 0); $lightColor = array('color', 255, 255, 255); $threshold = 0.43; - if ( $args[0] == 'list' ) { $inputColor = ( isset($args[2][0]) ) ? $this->assertColor($args[2][0]) : $lightColor; $darkColor = ( isset($args[2][1]) ) ? $this->assertColor($args[2][1]) : $darkColor; $lightColor = ( isset($args[2][2]) ) ? $this->assertColor($args[2][2]) : $lightColor; - $threshold = ( isset($args[2][3]) ) ? $this->assertNumber($args[2][3]) : $threshold; + + if( isset($args[2][3]) ) { + if( isset($args[2][3][2]) && $args[2][3][2] == '%' ) { + $args[2][3][1] /= 100; + unset($args[2][3][2]); + } + $threshold = $this->assertNumber($args[2][3]); + } } else { $inputColor = $this->assertColor($args);