/**
  * {@inheritdoc}
  */
 protected function doGenerate(CanvasInterface $canvas)
 {
     $width = $canvas->getWidth();
     $height = $canvas->getHeight();
     $n = max($width, $height) / 2;
     $rect = new Rectangle();
     $rect->fill(true);
     for ($i = 0; $i < $n; $i += $this->getStep() + 1) {
         $rect->getStart()->move($i * $width / $height, $i * $height / $width);
         $rect->getDimension()->resize($width - $i * $width / $height - $rect->getStart()->getX(), $height - $i * $height / $width - $rect->getStart()->getY());
         $rect->setColor($this->getColor($i / $n))->draw($canvas);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function doGenerate(CanvasInterface $canvas)
 {
     $n = $w = null;
     if (self::GRADIENT_VERTICAL == $this->getType()) {
         $n = $canvas->getHeight();
         $w = $canvas->getWidth();
     } else {
         $w = $canvas->getHeight();
         $n = $canvas->getWidth();
     }
     $rect = new Rectangle();
     $rect->fill(true);
     for ($i = 0; $i < $n; $i += $this->getStep() + 1) {
         if (self::GRADIENT_VERTICAL == $this->getType()) {
             $rect->getStart()->move(0, $i);
             $rect->getDimension()->resize($w, $i + $this->getStep());
         } else {
             $rect->getStart()->move($i, 0);
             $rect->getDimension()->resize($i + $this->getStep(), $w);
         }
         $rect->setColor($this->getColor($i / $n))->draw($canvas);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $colors = array(new RGBColor(0, 0, 150, 100), new RGBColor(255, 0, 0, 100), new RGBColor(0, 0, 0, 100), new RGBColor(150, 0, 0, 100), new RGBColor(255, 204, 0, 100), new RGBColor(100, 100, 100, 100));
     $width = round($canvas->getWidth() / 6);
     $dimension = new Dimension($width, $canvas->getHeight());
     $rect = new Rectangle($dimension);
     $rect->fill(true);
     for ($i = 0; $i < 6; $i++) {
         $rect->getStart()->move($width * $i, 0);
         $rect->setColor($colors[$i])->draw($canvas);
     }
     $actions = array(new Smooth(20), new Color\Contrast(35));
     foreach ($actions as $action) {
         $action->apply($canvas);
     }
 }