function ctools_stylizer_image_processor::command_gradient in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/stylizer.inc \ctools_stylizer_image_processor::command_gradient()
File
- includes/
stylizer.inc, line 427 - Create customized CSS and images from palettes created by user input.
Class
Code
function command_gradient($from, $to, $x, $y, $width, $height, $direction = 'down') {
$this
->log("Gradient: {$from} to {$to} ({$x}, {$y}, {$width}, {$height}) {$direction}");
if ($direction == 'down') {
for ($i = 0; $i < $height; ++$i) {
$color = ctools_color_blend($this->workspace, $this->palette[$from], $this->palette[$to], $i / ($height - 1));
imagefilledrectangle($this->workspace, $x, $y + $i, $x + $width, $y + $i + 1, $color);
}
}
else {
for ($i = 0; $i < $width; ++$i) {
$color = ctools_color_blend($this->workspace, $this->palette[$from], $this->palette[$to], $i / ($width - 1));
imagefilledrectangle($this->workspace, $x + $i, $y, $x + $i + 1, $y + $height, $color);
}
}
}