@@ 3238-3252 (lines=15) @@ | ||
3235 | /** |
|
3236 | * @param Less_Tree_Dimension $amount |
|
3237 | */ |
|
3238 | public function desaturate($color = null, $amount = null){ |
|
3239 | if (!$color instanceof Less_Tree_Color) { |
|
3240 | throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3241 | } |
|
3242 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3243 | throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3244 | } |
|
3245 | ||
3246 | $hsl = $color->toHSL(); |
|
3247 | ||
3248 | $hsl['s'] -= $amount->value / 100; |
|
3249 | $hsl['s'] = self::clamp($hsl['s']); |
|
3250 | ||
3251 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3252 | } |
|
3253 | ||
3254 | ||
3255 | ||
@@ 3256-3270 (lines=15) @@ | ||
3253 | ||
3254 | ||
3255 | ||
3256 | public function lighten($color = null, $amount=null){ |
|
3257 | if (!$color instanceof Less_Tree_Color) { |
|
3258 | throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3259 | } |
|
3260 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3261 | throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3262 | } |
|
3263 | ||
3264 | $hsl = $color->toHSL(); |
|
3265 | ||
3266 | $hsl['l'] += $amount->value / 100; |
|
3267 | $hsl['l'] = self::clamp($hsl['l']); |
|
3268 | ||
3269 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3270 | } |
|
3271 | ||
3272 | public function darken($color = null, $amount = null){ |
|
3273 | if (!$color instanceof Less_Tree_Color) { |
|
@@ 3272-3285 (lines=14) @@ | ||
3269 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3270 | } |
|
3271 | ||
3272 | public function darken($color = null, $amount = null){ |
|
3273 | if (!$color instanceof Less_Tree_Color) { |
|
3274 | throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3275 | } |
|
3276 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3277 | throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3278 | } |
|
3279 | ||
3280 | $hsl = $color->toHSL(); |
|
3281 | $hsl['l'] -= $amount->value / 100; |
|
3282 | $hsl['l'] = self::clamp($hsl['l']); |
|
3283 | ||
3284 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3285 | } |
|
3286 | ||
3287 | public function fadein($color = null, $amount = null){ |
|
3288 | if (!$color instanceof Less_Tree_Color) { |
|
@@ 3287-3299 (lines=13) @@ | ||
3284 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3285 | } |
|
3286 | ||
3287 | public function fadein($color = null, $amount = null){ |
|
3288 | if (!$color instanceof Less_Tree_Color) { |
|
3289 | throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3290 | } |
|
3291 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3292 | throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3293 | } |
|
3294 | ||
3295 | $hsl = $color->toHSL(); |
|
3296 | $hsl['a'] += $amount->value / 100; |
|
3297 | $hsl['a'] = self::clamp($hsl['a']); |
|
3298 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3299 | } |
|
3300 | ||
3301 | public function fadeout($color = null, $amount = null){ |
|
3302 | if (!$color instanceof Less_Tree_Color) { |
|
@@ 3301-3313 (lines=13) @@ | ||
3298 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3299 | } |
|
3300 | ||
3301 | public function fadeout($color = null, $amount = null){ |
|
3302 | if (!$color instanceof Less_Tree_Color) { |
|
3303 | throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3304 | } |
|
3305 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3306 | throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3307 | } |
|
3308 | ||
3309 | $hsl = $color->toHSL(); |
|
3310 | $hsl['a'] -= $amount->value / 100; |
|
3311 | $hsl['a'] = self::clamp($hsl['a']); |
|
3312 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3313 | } |
|
3314 | ||
3315 | public function fade($color = null, $amount = null){ |
|
3316 | if (!$color instanceof Less_Tree_Color) { |
|
@@ 3315-3328 (lines=14) @@ | ||
3312 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3313 | } |
|
3314 | ||
3315 | public function fade($color = null, $amount = null){ |
|
3316 | if (!$color instanceof Less_Tree_Color) { |
|
3317 | throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3318 | } |
|
3319 | if (!$amount instanceof Less_Tree_Dimension) { |
|
3320 | throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
3321 | } |
|
3322 | ||
3323 | $hsl = $color->toHSL(); |
|
3324 | ||
3325 | $hsl['a'] = $amount->value / 100; |
|
3326 | $hsl['a'] = self::clamp($hsl['a']); |
|
3327 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
|
3328 | } |
|
3329 | ||
3330 | ||
3331 |