You are here

function ctools_stylizer_image_processor::command_gradient in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/stylizer.inc \ctools_stylizer_image_processor::command_gradient()

File

includes/stylizer.inc, line 419
Create customized CSS and images from palettes created by user input.

Class

ctools_stylizer_image_processor

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 = _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 = _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);
    }
  }
}