You are here

public function PositionedRectangle::getSubGridDimensions in Image Effects 8.3

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

Get the width and height dimensions of the portion of a grid.

Parameters

string $id: An identifier of the grid.

int $x: The top-left point of the grid portion.

int $y: The top-left point of the grid portion.

int $rows_span: The number of rows of the grid portion.

int $columns_span: The number of columns of the grid portion.

Return value

int[] An array with width and height of the protion of the grid.

File

src/Component/PositionedRectangle.php, line 200

Class

PositionedRectangle
Rectangle algebra class.

Namespace

Drupal\image_effects\Component

Code

public function getSubGridDimensions($id, $x, $y, $rows_span, $columns_span) {
  $coord_tl = $this
    ->getPoint($id . '_' . $x . '_' . $y);
  $coord_br = $this
    ->getPoint($id . '_' . ($x + $rows_span) . '_' . ($y + $columns_span));
  return [
    $coord_br[0] - $coord_tl[0],
    $coord_br[1] - $coord_tl[1],
  ];
}