MDL-51530 libraries: Upgrade less.php to 1.7.0.9
This commit is contained in:
committed by
Ryan Wyllie
parent
fd57d685c7
commit
df09876082
+236
-65
@@ -17,11 +17,10 @@ class Less_Functions{
|
||||
$this->currentFileInfo = $currentFileInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $op
|
||||
*/
|
||||
public static function operate( $op, $a, $b ){
|
||||
public static function operate( $op, $a, $b ){
|
||||
switch ($op) {
|
||||
case '+': return $a + $b;
|
||||
case '-': return $a - $b;
|
||||
@@ -47,7 +46,7 @@ class Less_Functions{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function number($n){
|
||||
public static function number($n){
|
||||
|
||||
if ($n instanceof Less_Tree_Dimension) {
|
||||
return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value);
|
||||
@@ -58,7 +57,7 @@ class Less_Functions{
|
||||
}
|
||||
}
|
||||
|
||||
public static function scaled($n, $size = 255 ){
|
||||
public static function scaled($n, $size = 255 ){
|
||||
if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){
|
||||
return (float)$n->value * $size / 100;
|
||||
} else {
|
||||
@@ -66,11 +65,14 @@ class Less_Functions{
|
||||
}
|
||||
}
|
||||
|
||||
public function rgb ($r, $g, $b){
|
||||
public function rgb ($r = null, $g = null, $b = null){
|
||||
if (is_null($r) || is_null($g) || is_null($b)) {
|
||||
throw new Less_Exception_Compiler("rgb expects three parameters");
|
||||
}
|
||||
return $this->rgba($r, $g, $b, 1.0);
|
||||
}
|
||||
|
||||
public function rgba($r, $g, $b, $a){
|
||||
public function rgba($r = null, $g = null, $b = null, $a = null){
|
||||
$rgb = array($r, $g, $b);
|
||||
$rgb = array_map(array('Less_Functions','scaled'),$rgb);
|
||||
|
||||
@@ -144,59 +146,107 @@ class Less_Functions{
|
||||
$a);
|
||||
}
|
||||
|
||||
public function hue($color){
|
||||
public function hue($color = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to hue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$c = $color->toHSL();
|
||||
return new Less_Tree_Dimension(Less_Parser::round($c['h']));
|
||||
}
|
||||
|
||||
public function saturation($color){
|
||||
public function saturation($color = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to saturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$c = $color->toHSL();
|
||||
return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%');
|
||||
}
|
||||
|
||||
public function lightness($color){
|
||||
public function lightness($color = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to lightness must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$c = $color->toHSL();
|
||||
return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%');
|
||||
}
|
||||
|
||||
public function hsvhue( $color ){
|
||||
public function hsvhue( $color = null ){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to hsvhue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsv = $color->toHSV();
|
||||
return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) );
|
||||
}
|
||||
|
||||
|
||||
public function hsvsaturation( $color ){
|
||||
public function hsvsaturation( $color = null ){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsv = $color->toHSV();
|
||||
return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' );
|
||||
}
|
||||
|
||||
public function hsvvalue( $color ){
|
||||
public function hsvvalue( $color = null ){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsv = $color->toHSV();
|
||||
return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' );
|
||||
}
|
||||
|
||||
public function red($color) {
|
||||
public function red($color = null) {
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return new Less_Tree_Dimension( $color->rgb[0] );
|
||||
}
|
||||
|
||||
public function green($color) {
|
||||
public function green($color = null) {
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return new Less_Tree_Dimension( $color->rgb[1] );
|
||||
}
|
||||
|
||||
public function blue($color) {
|
||||
public function blue($color = null) {
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return new Less_Tree_Dimension( $color->rgb[2] );
|
||||
}
|
||||
|
||||
public function alpha($color){
|
||||
public function alpha($color = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$c = $color->toHSL();
|
||||
return new Less_Tree_Dimension($c['a']);
|
||||
}
|
||||
|
||||
public function luma ($color) {
|
||||
public function luma ($color = null) {
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to luma must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%');
|
||||
}
|
||||
|
||||
public function luminance( $color ){
|
||||
public function luminance( $color = null ){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to luminance must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$luminance =
|
||||
(0.2126 * $color->rgb[0] / 255)
|
||||
+ (0.7152 * $color->rgb[1] / 255)
|
||||
@@ -205,12 +255,20 @@ class Less_Functions{
|
||||
return new Less_Tree_Dimension(Less_Parser::round( $luminance * $color->alpha * 100), '%');
|
||||
}
|
||||
|
||||
public function saturate($color, $amount = null){
|
||||
public function saturate($color = null, $amount = null){
|
||||
// filter: saturate(3.2);
|
||||
// should be kept as is, so check for color
|
||||
if( !property_exists($color,'rgb') ){
|
||||
if ($color instanceof Less_Tree_Dimension) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to saturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to saturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
|
||||
$hsl['s'] += $amount->value / 100;
|
||||
@@ -222,7 +280,14 @@ class Less_Functions{
|
||||
/**
|
||||
* @param Less_Tree_Dimension $amount
|
||||
*/
|
||||
public function desaturate($color, $amount){
|
||||
public function desaturate($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
|
||||
$hsl['s'] -= $amount->value / 100;
|
||||
@@ -233,7 +298,14 @@ class Less_Functions{
|
||||
|
||||
|
||||
|
||||
public function lighten($color, $amount){
|
||||
public function lighten($color = null, $amount=null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
|
||||
$hsl['l'] += $amount->value / 100;
|
||||
@@ -242,34 +314,57 @@ class Less_Functions{
|
||||
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
|
||||
}
|
||||
|
||||
public function darken($color, $amount){
|
||||
|
||||
if( $color instanceof Less_Tree_Color ){
|
||||
$hsl = $color->toHSL();
|
||||
$hsl['l'] -= $amount->value / 100;
|
||||
$hsl['l'] = self::clamp($hsl['l']);
|
||||
|
||||
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
|
||||
public function darken($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
Less_Functions::Expected('color',$color);
|
||||
$hsl = $color->toHSL();
|
||||
$hsl['l'] -= $amount->value / 100;
|
||||
$hsl['l'] = self::clamp($hsl['l']);
|
||||
|
||||
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
|
||||
}
|
||||
|
||||
public function fadein($color, $amount){
|
||||
public function fadein($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
$hsl['a'] += $amount->value / 100;
|
||||
$hsl['a'] = self::clamp($hsl['a']);
|
||||
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
|
||||
}
|
||||
|
||||
public function fadeout($color, $amount){
|
||||
public function fadeout($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
$hsl['a'] -= $amount->value / 100;
|
||||
$hsl['a'] = self::clamp($hsl['a']);
|
||||
return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
|
||||
}
|
||||
|
||||
public function fade($color, $amount){
|
||||
public function fade($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
|
||||
$hsl['a'] = $amount->value / 100;
|
||||
@@ -279,7 +374,14 @@ class Less_Functions{
|
||||
|
||||
|
||||
|
||||
public function spin($color, $amount){
|
||||
public function spin($color = null, $amount = null){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to spin must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$amount instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The second argument to spin must be a number' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$hsl = $color->toHSL();
|
||||
$hue = fmod($hsl['h'] + $amount->value, 360);
|
||||
|
||||
@@ -296,10 +398,19 @@ class Less_Functions{
|
||||
/**
|
||||
* @param Less_Tree_Color $color1
|
||||
*/
|
||||
public function mix($color1, $color2, $weight = null){
|
||||
public function mix($color1 = null, $color2 = null, $weight = null){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to mix must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to mix must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$weight) {
|
||||
$weight = new Less_Tree_Dimension('50', '%');
|
||||
}
|
||||
if (!$weight instanceof Less_Tree_Dimension) {
|
||||
throw new Less_Exception_Compiler('The third argument to contrast must be a percentage' . ($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
$p = $weight->value / 100.0;
|
||||
$w = $p * 2 - 1;
|
||||
@@ -320,14 +431,14 @@ class Less_Functions{
|
||||
}
|
||||
|
||||
public function greyscale($color){
|
||||
return $this->desaturate($color, new Less_Tree_Dimension(100));
|
||||
return $this->desaturate($color, new Less_Tree_Dimension(100,'%'));
|
||||
}
|
||||
|
||||
|
||||
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') ){
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
return null;
|
||||
}
|
||||
if( !$light ){
|
||||
@@ -336,6 +447,14 @@ class Less_Functions{
|
||||
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;
|
||||
@@ -430,7 +549,7 @@ class Less_Functions{
|
||||
return new Less_Tree_Quoted( $string->quote , $result, $string->escaped);
|
||||
}
|
||||
|
||||
public function unit( $val, $unit = null) {
|
||||
public function unit( $val, $unit = null) {
|
||||
if( !($val instanceof Less_Tree_Dimension) ){
|
||||
throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') );
|
||||
}
|
||||
@@ -445,7 +564,7 @@ class Less_Functions{
|
||||
$unit = "";
|
||||
}
|
||||
return new Less_Tree_Dimension($val->value, $unit );
|
||||
}
|
||||
}
|
||||
|
||||
public function convert($val, $unit){
|
||||
return $val->convertTo($unit->value);
|
||||
@@ -585,7 +704,7 @@ class Less_Functions{
|
||||
|
||||
if( $order[$j]->unit->toString() === "" && $unitClone ){
|
||||
$temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone);
|
||||
$referenceUnified = $temp->unifiy();
|
||||
$referenceUnified = $temp->unify();
|
||||
}else{
|
||||
$referenceUnified = $order[$j]->unify();
|
||||
}
|
||||
@@ -619,6 +738,10 @@ class Less_Functions{
|
||||
}
|
||||
|
||||
public function argb($color) {
|
||||
if (!$color instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return new Less_Tree_Anonymous($color->toARGB());
|
||||
}
|
||||
|
||||
@@ -875,21 +998,6 @@ class Less_Functions{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
private static function Expected( $type, $arg ){
|
||||
|
||||
$debug = debug_backtrace();
|
||||
array_shift($debug);
|
||||
$last = array_shift($debug);
|
||||
$last = array_intersect_key($last,array('function'=>'','class'=>'','line'=>''));
|
||||
|
||||
$message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `'.$type.'`. '.$arg->toCSS().'. '.print_r($last,true);
|
||||
throw new Less_Exception_Compiler($message);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Php version of javascript's `encodeURIComponent` function
|
||||
*
|
||||
@@ -924,7 +1032,14 @@ class Less_Functions{
|
||||
return new Less_Tree_Color($r, $ar);
|
||||
}
|
||||
|
||||
public function multiply($color1, $color2 ){
|
||||
public function multiply($color1 = null, $color2 = null ){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -932,7 +1047,14 @@ class Less_Functions{
|
||||
return $cb * $cs;
|
||||
}
|
||||
|
||||
public function screen($color1, $color2 ){
|
||||
public function screen($color1 = null, $color2 = null ){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -940,7 +1062,14 @@ class Less_Functions{
|
||||
return $cb + $cs - $cb * $cs;
|
||||
}
|
||||
|
||||
public function overlay($color1, $color2){
|
||||
public function overlay($color1 = null, $color2 = null){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -951,7 +1080,14 @@ class Less_Functions{
|
||||
: $this->colorBlendScreen($cb - 1, $cs);
|
||||
}
|
||||
|
||||
public function softlight($color1, $color2){
|
||||
public function softlight($color1 = null, $color2 = null){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -966,7 +1102,14 @@ class Less_Functions{
|
||||
return $cb - (1 - 2 * $cs) * $e * ($d - $cb);
|
||||
}
|
||||
|
||||
public function hardlight($color1, $color2){
|
||||
public function hardlight($color1 = null, $color2 = null){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -974,7 +1117,14 @@ class Less_Functions{
|
||||
return $this->colorBlendOverlay($cs, $cb);
|
||||
}
|
||||
|
||||
public function difference($color1, $color2) {
|
||||
public function difference($color1 = null, $color2 = null) {
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -982,7 +1132,14 @@ class Less_Functions{
|
||||
return abs($cb - $cs);
|
||||
}
|
||||
|
||||
public function exclusion( $color1, $color2 ){
|
||||
public function exclusion( $color1 = null, $color2 = null ){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -990,7 +1147,14 @@ class Less_Functions{
|
||||
return $cb + $cs - 2 * $cb * $cs;
|
||||
}
|
||||
|
||||
public function average($color1, $color2){
|
||||
public function average($color1 = null, $color2 = null){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 );
|
||||
}
|
||||
|
||||
@@ -999,7 +1163,14 @@ class Less_Functions{
|
||||
return ($cb + $cs) / 2;
|
||||
}
|
||||
|
||||
public function negation($color1, $color2 ){
|
||||
public function negation($color1 = null, $color2 = null ){
|
||||
if (!$color1 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
if (!$color2 instanceof Less_Tree_Color) {
|
||||
throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
||||
}
|
||||
|
||||
return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user