public static function SassExtentionsCompassFunctionsColourStops::grad_position in Sassy 7
1 call to SassExtentionsCompassFunctionsColourStops::grad_position()
- SassExtentionsCompassFunctionsColourStops::grad_end_position in phamlp/
sass/ extensions/ compass/ functions/ colourStops.php
File
- phamlp/
sass/ extensions/ compass/ functions/ colourStops.php, line 130
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_position($colourList, $index, $default, $radial = null) {
SassLiteral::assertType($colourList, 'CompassList');
if (is_null($radial)) {
$radial = new SassBoolean(false);
}
else {
SassLiteral::assertType($radial, 'SassBoolean');
}
$stop = $colourList->values[$index->value - 1]->stop;
if ($stop && $radial->value) {
$orig_stop = $stop;
if ($stop
->isUnitless()) {
if ($stop->value <= 1) {
# A unitless number is assumed to be a percentage when it's between 0 and 1
$stop = $stop
->op_times(new SassNumber('100%'));
}
else {
# Otherwise, a unitless number is assumed to be in pixels
$stop = $stop
->op_times(new SassNumber('1px'));
}
}
if ($stop->numeratorUnits === '%' && isset($colourList->values[sizeof($colourList->values) - 1]->stop) && $colourList->values[sizeof($colourList->values) - 1]->stop->numeratorUnits === 'px') {
$stop = $stop
->op_times($colourList->values[sizeof($colourList->values) - 1]->stop)
->op_div(new SassNumber('100%'));
}
//Compass::Logger.new.record(:warning, "Webkit only supports pixels for the start and end stops for radial gradients. Got: #{orig_stop}") if stop.numerator_units != ["px"];
return $stop
->op_div(new SassNumber('1' . $stop->units));
}
elseif ($stop) {
return $stop;
}
else {
return $default;
}
}