You are here

protected function TextimageTextbox::rotateBoxPoints in Textimage 7.3

Rotate the box.

Parameters

float $angle: rotation angle

array $top_left_corner_position: box translation offset array (x, y) to reposition the box

File

classes/TextimageTextbox.inc, line 95
Textimage - Font textbox management class.

Class

TextimageTextbox
Textimage - Font textbox management class.

Code

protected function rotateBoxPoints($angle, $top_left_corner_position) {
  for ($i = 0; $i < 7; $i += 2) {
    list($this->points[$i], $this->points[$i + 1]) = self::rotatePoint($this->points[$i], $this->points[$i + 1], $angle, $top_left_corner_position);
  }
  list($this->basepoint[0], $this->basepoint[1]) = self::rotatePoint($this->basepoint[0], $this->basepoint[1], $angle, $top_left_corner_position);
  if (!$top_left_corner_position) {
    $min_x = min(array(
      $this->points[0],
      $this->points[2],
      $this->points[4],
      $this->points[6],
    ));
    $min_y = min(array(
      $this->points[1],
      $this->points[3],
      $this->points[5],
      $this->points[7],
    ));
    $max_x = max(array(
      $this->points[0],
      $this->points[2],
      $this->points[4],
      $this->points[6],
    ));
    $max_y = max(array(
      $this->points[1],
      $this->points[3],
      $this->points[5],
      $this->points[7],
    ));
    $this->width = $max_x - $min_x + 1;
    $this->height = $max_y - $min_y + 1;
    $this->topLeftCornerPosition = array(
      -$min_x,
      -$min_y,
    );
    $this
      ->translateBoxPoints($this->topLeftCornerPosition);
  }
}