예제 #1
0
 public function testRotatePoint()
 {
     $this->assertEquals(['x' => 10, 'y' => 0], Geometry::rotatePoint(0, 0, 5, 5, 90));
     $this->assertEquals(['x' => 10, 'y' => 10], Geometry::rotatePoint(0, 0, 5, 5, 180));
     $this->assertEquals(['x' => 0, 'y' => 0], Geometry::rotatePoint(0, 0, 5, 5, 360));
     $this->assertEquals(['x' => 10, 'y' => 0], Geometry::rotatePoint(0, 0, 5, 5, 450));
 }
예제 #2
0
 public function rotateImageAroundAxis($degrees, $ax = null, $ay = null)
 {
     if ($degrees) {
         $newCoordinates = Geometry::calcCoordinatesForRotateObjectInscribedInRectangular(0, 0, $this->getImageWidth(), $this->getImageHeight(), $degrees, $ax, $ay);
         $this->setImageX($this->getImageX() + $newCoordinates['x'])->setImageY($this->getImageY() + $newCoordinates['y']);
         // $background = 'graya(50%, 0.5)';
         // $this->rotateImage($background, $degrees);
         $this->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
         $this->distortImage(Imagick::DISTORTION_SCALEROTATETRANSLATE, [$this->getImageWidth() / 2, $this->getImageHeight() / 2, 1, $degrees], true);
     }
     return $this;
 }