You are here

public function SassColour::with in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassColour.php \SassColour::with()

* Returns a copy of this colour with one or more channels changed. * RGB or HSL attributes may be changed, but not both at once. *

Parameters

array attributes to change:

File

phamlp/sass/script/literals/SassColour.php, line 591

Class

SassColour
SassColour class. A SassScript object representing a CSS colour.

Code

public function with($attributes) {
  if ($this
    ->assertValid($attributes, false) === 'hsl') {
    $colour = array_merge(array(
      'hue' => $this
        ->getHue(),
      'saturation' => $this
        ->getSaturation(),
      'lightness' => $this
        ->getLightness(),
      'alpha' => $this->alpha,
    ), $attributes);
  }
  else {
    $colour = array_merge(array(
      'red' => $this
        ->getRed(),
      'green' => $this
        ->getGreen(),
      'blue' => $this
        ->getBlue(),
      'alpha' => $this->alpha,
    ), $attributes);
  }
  return new SassColour($colour);
}