Skip to content

Commit

Permalink
contrast() now accepts percentage threshold
Browse files Browse the repository at this point in the history
Fixes leafo#501
  • Loading branch information
atkaye committed Dec 21, 2013
1 parent 33a82c3 commit cdcd77b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lessc.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cdcd77b

Please sign in to comment.