Ejemplo n.º 1
0
 public function testEquals()
 {
     $line = new Line(new Coordinate(0, 0), new Coordinate(100, 100));
     $clone = clone $line;
     $this->assertTrue($line->equals($clone));
     $clone->getStart()->move(10, 10);
     $this->assertFalse($line->equals($clone));
     $clone->getStart()->move(0, 0);
     $clone->getEnd()->move(50, 50);
     $this->assertFalse($line->equals($clone));
     $clone->getEnd()->move(100, 100);
     $clone->getColor()->setRed(255);
     $this->assertFalse($line->equals($clone));
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $width = $canvas->getWidth();
     $height = $canvas->getHeight();
     $line = new Line();
     $line->setColor($this->getColor());
     for ($x = 1; $x <= $width; $x += $this->getSize()) {
         $line->getStart()->move($x, 0);
         $line->getEnd()->move($x, $height);
         $line->draw($canvas);
     }
     for ($y = 1; $y <= $height; $y += $this->getSize()) {
         $line->getStart()->move(0, $y);
         $line->getEnd()->move($width, $y);
         $line->draw($canvas);
     }
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $c1 = clone $this->getFirstColor();
     $c2 = clone $this->getSecondColor();
     $line = new Line();
     $width = $canvas->getWidth();
     $height = $canvas->getHeight();
     for ($i = 0; $i < $this->getWidth(); $i++) {
         $alpha = round($i / $this->getWidth() * 127);
         $c1->setAlpha($alpha);
         $c2->setAlpha($alpha);
         $line->setStart(new Coordinate($i, $i + 1))->setEnd(new Coordinate($i, $height - $i - 1))->setColor($c1)->draw($canvas)->setStart(new Coordinate($i, $i))->setEnd(new Coordinate($width - $i, $i))->draw($canvas)->setStart(new Coordinate($width - $i, $height - $i - 1))->setEnd(new Coordinate($width - $i, $i + 1))->setColor($c2)->draw($canvas)->setStart(new Coordinate($width - $i, $height - $i - 1))->setEnd(new Coordinate($i, $height - $i))->draw($canvas);
     }
 }