public function contrast( $color, $dark = null, $light = null, $threshold = null){ // filter: contrast(3.2); // should be kept as is, so check for color if( !property_exists($color,'rgb') ){ return null; } if( !$light ){ $light = $this->rgba(255, 255, 255, 1.0); } if( !$dark ){ $dark = $this->rgba(0, 0, 0, 1.0); } //Figure out which is actually light and dark! if( $dark->luma() > $light->luma() ){ $t = $light; $light = $dark; $dark = $t; } if( !$threshold ){ $threshold = 0.43; } else { $threshold = Less_Functions::number($threshold); } if( $color->luma() < $threshold ){ return $light; } else { return $dark; } }
public function contrast($color, $dark = null, $light = null, $threshold = null) { // filter: contrast(3.2); // should be kept as is, so check for color if (!$color instanceof Less_Tree_Color) { return null; } if (!$light) { $light = $this->rgba(255, 255, 255, 1.0); } if (!$dark) { $dark = $this->rgba(0, 0, 0, 1.0); } if (!$dark instanceof Less_Tree_Color) { throw new Less_Exception_Compiler('The second argument to contrast must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); } if (!$light instanceof Less_Tree_Color) { throw new Less_Exception_Compiler('The third argument to contrast must be a color' . ($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); } //Figure out which is actually light and dark! if ($dark->luma() > $light->luma()) { $t = $light; $light = $dark; $dark = $t; } if (!$threshold) { $threshold = 0.43; } else { $threshold = Less_Functions::number($threshold); } if ($color->luma() < $threshold) { return $light; } else { return $dark; } }
public function contrast($color, $dark = null, $light = null, $threshold = null) { if (!$color instanceof Less_Tree_Color) { return null; }if (!$light) { $light = $this->rgba(255, 255, 255, 1.0); }if (!$dark) { $dark = $this->rgba(0, 0, 0, 1.0); }if (!$dark instanceof Less_Tree_Color) { throw new Less_Exception_Compiler('The second argument to contrast must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); }if (!$light instanceof Less_Tree_Color) { throw new Less_Exception_Compiler('The third argument to contrast must be a color' . ($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); }if ($dark->luma() > $light->luma()) { $t = $light; $light = $dark; $dark = $t; }if (!$threshold) { $threshold = 0.43; } else { $threshold = Less_Functions::number($threshold); }if ($color->luma() < $threshold) { return $light; } else { return $dark; } }