You are here

private static function SassScriptFunctions::adjust in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/SassScriptFunctions.php \SassScriptFunctions::adjust()

* Adjusts the colour *

Parameters

SassColour the colour to adjust: * @param SassNumber the amount to adust by * @param boolean whether the amount is a proportion of the current value or * the total range * @param string the attribute to adjust * @param boolean whether to decrease (false) or increase (true) the value of the attribute * @param float minimum value the amount can be * @param float maximum value the amount can bemixed * @param string amount units

6 calls to SassScriptFunctions::adjust()
SassScriptFunctions::darken in phamlp/sass/script/SassScriptFunctions.php
* Makes a colour darker. *
SassScriptFunctions::desaturate in phamlp/sass/script/SassScriptFunctions.php
* Makes a colour less saturated. *
SassScriptFunctions::lighten in phamlp/sass/script/SassScriptFunctions.php
* Makes a colour lighter. *
SassScriptFunctions::opacify in phamlp/sass/script/SassScriptFunctions.php
* Makes a colour more opaque. *
SassScriptFunctions::saturate in phamlp/sass/script/SassScriptFunctions.php
* Makes a colour more saturated. *

... See full list

File

phamlp/sass/script/SassScriptFunctions.php, line 532

Class

SassScriptFunctions
SassScript functions class. A collection of functions for use in SassSCript. @package PHamlP @subpackage Sass.script

Code

private static function adjust($colour, $amount, $ofCurrent, $attribute, $op, $min, $max, $units = '') {
  SassLiteral::assertType($colour, 'SassColour');
  SassLiteral::assertType($amount, 'SassNumber');
  SassLiteral::assertInRange($amount, $min, $max, $units);
  if (!is_bool($ofCurrent)) {
    SassLiteral::assertType($ofCurrent, 'SassBoolean');
    $ofCurrent = $ofCurrent->value;
  }
  $amount = $amount->value * ($attribute === 'alpha' && $ofCurrent && $units === '' ? 100 : 1);
  return $colour
    ->with(array(
    $attribute => self::inRange($ofCurrent ? $colour->{$attribute} * (1 + $amount * ($op === self::INCREASE ? 1 : -1) / 100) : $colour->{$attribute} + $amount * ($op === self::INCREASE ? 1 : -1), $min, $max),
  ));
}