You are here

public static function SassExtentionsCompassFunctionsColourStops::grad_colour_stops in Sassy 7

1 call to SassExtentionsCompassFunctionsColourStops::grad_colour_stops()
SassExtentionsCompassFunctionsColourStops::grad_color_stops in phamlp/sass/extensions/compass/functions/colourStops.php

File

phamlp/sass/extensions/compass/functions/colourStops.php, line 91

Class

SassExtentionsCompassFunctionsColourStops
Compass extension SassScript colour stops functions class. A collection of functions for use in SassSCript. @package PHamlP @subpackage Sass.extensions.compass.functions

Code

public static function grad_colour_stops($colour_list) {
  SassLiteral::assertType($colour_list, 'CompassList');
  self::normalize_stops($colour_list);
  $v = array_reverse($colour_list->values);
  $max = $v[0]->stop;
  $last_value = null;
  $colourStops = array();
  foreach ($colour_list->values as $pos) {

    # have to convert absolute units to percentages for use in colour stop functions.
    $stop = $pos->stop;
    if ($stop->numeratorUnits === $max->numeratorUnits) {
      $stop = $stop
        ->op_div($max)
        ->op_times(new SassNumber('100%'));
    }

    # Make sure the colour stops are specified in the right order.
    if ($last_value && $last_value->value > $stop->value) {
      throw new SassScriptFunctionException('Colour stops must be specified in increasing order', array(), SassScriptParser::$context->node);
    }
    $last_value = $stop;
    $colourStops[] = "color-stop({$stop->toString()}, {$pos->colour->toString()})";
  }
  return new SassString(join(', ', $colourStops));
}