You are here

public function PositionedRectangle::rotate in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 src/Component/PositionedRectangle.php \Drupal\image_effects\Component\PositionedRectangle::rotate()
  2. 8 src/Component/PositionedRectangle.php \Drupal\image_effects\Component\PositionedRectangle::rotate()

Rotates the rectangle and any additional point.

Parameters

float $angle: Rotation angle.

File

src/Component/PositionedRectangle.php, line 342

Class

PositionedRectangle
Rectangle algebra class.

Namespace

Drupal\image_effects\Component

Code

public function rotate($angle) {
  if ($angle) {
    $this->angle = $angle;
    foreach ($this->points as &$point) {
      $this
        ->rotatePoint($point, $angle);
    }
    $this
      ->determineBoundingCorners();
    $this->rotationOffset = [
      -$this->points['o_a'][0],
      -$this->points['o_a'][1],
    ];
  }
  return $this;
}