You are here

public static function SassExtentionsCompassFunctionsColourStops::grad_point in Sassy 7

File

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

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_point($position) {
  $position = $position->value;
  if (strpos($position, ' ') !== false) {
    if (preg_match('/(top|bottom|center) (left|right|center)/', $position, $matches)) {
      $position = "{$matches[2]} {$matches[1]}";
    }
  }
  else {
    switch ($position) {
      case 'top':
      case 'bottom':
        $position = "left {$position}";
        break;
      case 'left':
      case 'right':
        $position .= ' top';
        break;
    }
  }
  return new SassString(preg_replace(array(
    '/top/',
    '/bottom/',
    '/left/',
    '/right/',
    '/center/',
  ), array(
    '0%',
    '100%',
    '0%',
    '100%',
    '50%',
  ), $position));
}