You are here

public static function SassScriptFunctions::adjust in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/script/SassScriptFunctions.php \SassScriptFunctions::adjust()

Adjusts the colour

Parameters

SassColour the colour to adjust:

SassNumber the amount to adust by:

boolean whether the amount is a proportion of the current value or: the total range

string the attribute to adjust:

boolean whether to decrease (false) or increase (true) the value of the attribute:

float minimum value the amount can be:

float maximum value the amount can bemixed:

string amount units:

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

... See full list

File

phpsass/script/SassScriptFunctions.php, line 539

Class

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

Code

public 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),
  ));
}