You are here

public function PositionedRectangle::setFromDimensions in Image Effects 8.2

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

Sets a rectangle from its width and height.

Parameters

int $width: The width of the rectangle.

int $height: The height of the rectangle.

Return value

$this

1 call to PositionedRectangle::setFromDimensions()
PositionedRectangle::__construct in src/Component/PositionedRectangle.php
Constructs a new PositionedRectangle object.

File

src/Component/PositionedRectangle.php, line 91

Class

PositionedRectangle
Rectangle algebra class.

Namespace

Drupal\image_effects\Component

Code

public function setFromDimensions($width, $height) {
  $this
    ->setFromCorners([
    'c_a' => [
      0,
      0,
    ],
    'c_b' => [
      $width - 1,
      0,
    ],
    'c_c' => [
      $width - 1,
      $height - 1,
    ],
    'c_d' => [
      0,
      $height - 1,
    ],
  ]);
  return $this;
}