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; }
public static function create_rgba($r, $g, $b, $a) { if (!class_exists('RgbaGd')) { include dirname(__FILE__) . '/libraries/rgbagd.php'; } $file = "color_r{$r}_g{$g}_b{$b}_a{$a}.png"; $alpha = intval(127 - 127 * $a); if (!Scaffold_Cache::exists('rgba/' . $file)) { Scaffold_Cache::create('rgba'); $file = Scaffold_Cache::find('rgba') . '/' . $file; $rgba = new RgbaGd($r, $g, $b, $alpha); $rgba->save($file); } $file = Scaffold_Cache::find('rgba') . '/' . $file; self::$rgba[] = array($r, $g, $b, $alpha); $properties = "\n\t\t\tbackground-position: top left;\n\t\t background-repeat: repeat;\n\t\t background-image: url(" . Scaffold::url_path($file) . ") !important;\n\t\t background-image:none;\n\t\t background: rgba({$r},{$g},{$b},{$a});\n\t\t filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" . Scaffold::url_path($file) . ", sizingMethod=scale);\n\t\t"; return $properties; }
/** * Generates the background grid.png * * @author Anthony Short * @param $cl Column width * @param $bl Baseline * @param $gw Gutter Width * @return null */ private static function create_grid_image($cw, $bl, $lgw, $rgw) { # Path to the image $file = "{$lgw}_{$cw}_{$rgw}_{$bl}_grid.png"; if (($cache = Scaffold_Cache::find('Layout/' . $file)) === false) { Scaffold_Cache::create('Layout'); $image = ImageCreate($cw + $lgw + $rgw, $bl); $colorWhite = ImageColorAllocate($image, 255, 255, 255); $colorGrey = ImageColorAllocate($image, 200, 200, 200); $colorBlue = ImageColorAllocate($image, 240, 240, 255); # Draw left gutter Imagefilledrectangle($image, 0, 0, $lgw - 1, $bl, $colorWhite); # Draw column Imagefilledrectangle($image, $lgw, 0, $cw + $lgw - 1, $bl, $colorBlue); # Draw right gutter Imagefilledrectangle($image, $lgw + $cw + 1, 0, $lgw + $cw + $rgw, $bl, $colorWhite); # Draw baseline imageline($image, 0, $bl - 1, $lgw + $cw + $rgw, $bl - 1, $colorGrey); $cache = Scaffold_Cache::find('Layout') . '/' . $file; ImagePNG($image, $cache); # Kill it ImageDestroy($image); } return Scaffold::url_path($cache); }