@@ 3990-3999 (lines=10) @@ | ||
3987 | return new Less_Tree_Color($r, $ar); |
|
3988 | } |
|
3989 | ||
3990 | public function multiply($color1 = null, $color2 = null ){ |
|
3991 | if (!$color1 instanceof Less_Tree_Color) { |
|
3992 | throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3993 | } |
|
3994 | if (!$color2 instanceof Less_Tree_Color) { |
|
3995 | throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3996 | } |
|
3997 | ||
3998 | return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 ); |
|
3999 | } |
|
4000 | ||
4001 | private function colorBlendMultiply($cb, $cs){ |
|
4002 | return $cb * $cs; |
|
@@ 4005-4014 (lines=10) @@ | ||
4002 | return $cb * $cs; |
|
4003 | } |
|
4004 | ||
4005 | public function screen($color1 = null, $color2 = null ){ |
|
4006 | if (!$color1 instanceof Less_Tree_Color) { |
|
4007 | throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4008 | } |
|
4009 | if (!$color2 instanceof Less_Tree_Color) { |
|
4010 | throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4011 | } |
|
4012 | ||
4013 | return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 ); |
|
4014 | } |
|
4015 | ||
4016 | private function colorBlendScreen( $cb, $cs){ |
|
4017 | return $cb + $cs - $cb * $cs; |
|
@@ 4020-4029 (lines=10) @@ | ||
4017 | return $cb + $cs - $cb * $cs; |
|
4018 | } |
|
4019 | ||
4020 | public function overlay($color1 = null, $color2 = null){ |
|
4021 | if (!$color1 instanceof Less_Tree_Color) { |
|
4022 | throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4023 | } |
|
4024 | if (!$color2 instanceof Less_Tree_Color) { |
|
4025 | throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4026 | } |
|
4027 | ||
4028 | return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 ); |
|
4029 | } |
|
4030 | ||
4031 | private function colorBlendOverlay($cb, $cs ){ |
|
4032 | $cb *= 2; |
|
@@ 4038-4047 (lines=10) @@ | ||
4035 | : $this->colorBlendScreen($cb - 1, $cs); |
|
4036 | } |
|
4037 | ||
4038 | public function softlight($color1 = null, $color2 = null){ |
|
4039 | if (!$color1 instanceof Less_Tree_Color) { |
|
4040 | throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4041 | } |
|
4042 | if (!$color2 instanceof Less_Tree_Color) { |
|
4043 | throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4044 | } |
|
4045 | ||
4046 | return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 ); |
|
4047 | } |
|
4048 | ||
4049 | private function colorBlendSoftlight($cb, $cs ){ |
|
4050 | $d = 1; |
|
@@ 4060-4069 (lines=10) @@ | ||
4057 | return $cb - (1 - 2 * $cs) * $e * ($d - $cb); |
|
4058 | } |
|
4059 | ||
4060 | public function hardlight($color1 = null, $color2 = null){ |
|
4061 | if (!$color1 instanceof Less_Tree_Color) { |
|
4062 | throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4063 | } |
|
4064 | if (!$color2 instanceof Less_Tree_Color) { |
|
4065 | throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4066 | } |
|
4067 | ||
4068 | return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 ); |
|
4069 | } |
|
4070 | ||
4071 | private function colorBlendHardlight( $cb, $cs ){ |
|
4072 | return $this->colorBlendOverlay($cs, $cb); |
|
@@ 4075-4084 (lines=10) @@ | ||
4072 | return $this->colorBlendOverlay($cs, $cb); |
|
4073 | } |
|
4074 | ||
4075 | public function difference($color1 = null, $color2 = null) { |
|
4076 | if (!$color1 instanceof Less_Tree_Color) { |
|
4077 | throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4078 | } |
|
4079 | if (!$color2 instanceof Less_Tree_Color) { |
|
4080 | throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4081 | } |
|
4082 | ||
4083 | return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 ); |
|
4084 | } |
|
4085 | ||
4086 | private function colorBlendDifference( $cb, $cs ){ |
|
4087 | return abs($cb - $cs); |
|
@@ 4090-4099 (lines=10) @@ | ||
4087 | return abs($cb - $cs); |
|
4088 | } |
|
4089 | ||
4090 | public function exclusion( $color1 = null, $color2 = null ){ |
|
4091 | if (!$color1 instanceof Less_Tree_Color) { |
|
4092 | throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4093 | } |
|
4094 | if (!$color2 instanceof Less_Tree_Color) { |
|
4095 | throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4096 | } |
|
4097 | ||
4098 | return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 ); |
|
4099 | } |
|
4100 | ||
4101 | private function colorBlendExclusion( $cb, $cs ){ |
|
4102 | return $cb + $cs - 2 * $cb * $cs; |
|
@@ 4105-4114 (lines=10) @@ | ||
4102 | return $cb + $cs - 2 * $cb * $cs; |
|
4103 | } |
|
4104 | ||
4105 | public function average($color1 = null, $color2 = null){ |
|
4106 | if (!$color1 instanceof Less_Tree_Color) { |
|
4107 | throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4108 | } |
|
4109 | if (!$color2 instanceof Less_Tree_Color) { |
|
4110 | throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4111 | } |
|
4112 | ||
4113 | return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 ); |
|
4114 | } |
|
4115 | ||
4116 | // non-w3c functions: |
|
4117 | public function colorBlendAverage($cb, $cs ){ |
|
@@ 4121-4130 (lines=10) @@ | ||
4118 | return ($cb + $cs) / 2; |
|
4119 | } |
|
4120 | ||
4121 | public function negation($color1 = null, $color2 = null ){ |
|
4122 | if (!$color1 instanceof Less_Tree_Color) { |
|
4123 | throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4124 | } |
|
4125 | if (!$color2 instanceof Less_Tree_Color) { |
|
4126 | throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
4127 | } |
|
4128 | ||
4129 | return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 ); |
|
4130 | } |
|
4131 | ||
4132 | public function colorBlendNegation($cb, $cs){ |
|
4133 | return 1 - abs($cb + $cs - 1); |