public static function create_gradient($direction, $size, $from, $to, $stops = false)
 {
     if (!class_exists('GradientGD')) {
         include dirname(__FILE__) . '/libraries/gradientgd.php';
     }
     $file = "{$direction}_{$size}_" . str_replace('#', '', $from) . "_" . str_replace('#', '', $to) . ".png";
     if ($direction == 'horizontal') {
         $height = 50;
         $width = $size;
         $repeat = 'y';
     } else {
         $height = $size;
         $width = 50;
         $repeat = 'x';
     }
     if (!Scaffold_Cache::exists('gradients/' . $file)) {
         Scaffold_Cache::create('gradients');
         $file = Scaffold_Cache::find('gradients') . '/' . $file;
         $gradient = new GradientGD($width, $height, $direction, $from, $to, $stops);
         $gradient->save($file);
     }
     $file = Scaffold_Cache::find('gradients') . '/' . $file;
     self::$gradients[] = array($direction, $size, $from, $to, $file);
     $properties = "\n\t\t\tbackground-position: top left;\n\t\t    background-repeat: repeat-{$repeat};\n\t\t    background-image: url(" . Scaffold::url_path($file) . ");\n\t\t";
     return $properties;
 }
Example #2
0
 public function create_gradient($direction, $size, $from, $to, $stops = false, $scaffold)
 {
     if (!class_exists('GradientGD')) {
         include dirname(__FILE__) . '/lib/gradientgd.php';
     }
     $file = "{$direction}_{$size}_" . str_replace('#', '', $from) . "_" . str_replace('#', '', $to) . ".png";
     if ($direction == 'horizontal') {
         $height = 50;
         $width = $size;
         $repeat = 'y';
     } else {
         $height = $size;
         $width = 50;
         $repeat = 'x';
     }
     if (!$scaffold->cache->exists('gradients' . DIRECTORY_SEPARATOR . $file)) {
         $scaffold->cache->create('gradients');
         $file = $scaffold->cache->find('gradients') . DIRECTORY_SEPARATOR . $file;
         $gradient = new GradientGD($width, $height, $direction, $from, $to, $stops);
         $gradient->save($file);
     }
     $file = $scaffold->cache->find('gradients') . DIRECTORY_SEPARATOR . $file;
     $this->gradients[] = array($direction, $size, $from, $to, $file);
     $file = substr($file, strpos($file, '/wp-content'));
     $properties = "\n\t\t\tbackground-position: top left;\n\t\t    background-repeat: repeat-{$repeat};\n\t\t    background-image: url('{$file}');\n\t\t";
     return $properties;
 }