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