setasign\SetaPDF2\Core\Geometry

Rectangle Class representing a rectangle

File: /SetaPDF v2/Core/Geometry/Rectangle.php
Old class name (alias): \SetaPDF_Core_Geometry_Rectangle

Class hierarchy

Implements

Summary

Properties

$_llX

private float Rectangle::$_llX

ll => lower left ur => upper right

$_llY

private float Rectangle::$_llY

ll => lower left ur => upper right

$_urX

private float Rectangle::$_urX

ll => lower left ur => upper right

$_urY

private float Rectangle::$_urY

ll => lower left ur => upper right


Methods

__construct()

public Rectangle::__construct (
int|float|Point $a,
int|float|Point $b,
int|float $c = null,
int|float $d = null
)

The constructor.

There three ways to create a rectangle:

- 2 params   \setasign\SetaPDF2\Core\Geometry\Point $a  point1
             \setasign\SetaPDF2\Core\Geometry\Point $b  point2

- 3 params   \setasign\SetaPDF2\Core\Geometry\Point $a pointLL
             int|float $b width
             int|float $c height

- 4 params   int|float $a x of point1
             int|float $b y of point1
             int|float $c x of point2
             int|float $d y of point2
Parameters
$a : int|float|Point

point1 OR pointLL OR x of point1

$b : int|float|Point

point2 OR width OR y of point1

$c : int|float

height OR x of point2

$d : int|float

none OR y of point2

Exceptions

Throws \InvalidArgumentException

_pointInside()

private Rectangle::_pointInside (
int|float $x,
int|float $y,
bool $ignoreEqual = false
): bool

Checks whether a point is inside or on the border of this rectangle.

Parameters
$x : int|float
 
$y : int|float
 
$ignoreEqual : bool

If the point lays on the border and this is true false will be returned

collides()

public Rectangle::collides (
Collidable $geometry
): bool

Checks if this geometry collides with another geometry.

Parameters
$geometry : Collidable
 

contains()

public Rectangle::contains (
Point|Rectangle $geometry
): bool

Checks whether this rectangle contains another geometric object.

Parameters
$geometry : Point|Rectangle
 
Exceptions

Throws \InvalidArgumentException

getDimensions()

public Rectangle::getDimensions (
void
): array

Returns the width and height of the rectangle.

getHeight()

public Rectangle::getHeight (
void
): float

Returns the actual height of the rectangle.

getLl()

public Rectangle::getLl (
void
): Point

Returns the lower left point of the rectangle.

Note: changing the returned point object don't changing the rectangle.

getLr()

public Rectangle::getLr (
void
): Point

Returns the lower right point of the rectangle.

Note: changing the returned point object don't changing the rectangle.

getUl()

public Rectangle::getUl (
void
): Point

Returns the upper left point of the rectangle.

Note: changing the returned point object don't changing the rectangle.

getUr()

public Rectangle::getUr (
void
): Point

Returns the upper right point of the rectangle.

Note: changing the returned point object don't changing the rectangle.

getWidth()

public Rectangle::getWidth (
void
): float

Returns the actual width of the rectangle.

init()

public Rectangle::init (
int|float $x1,
int|float $y1,
int|float $x2,
int|float $y2
): void

Reset the complete rectangle by using two opposite points of the new rectangle.

Parameters
$x1 : int|float
 
$y1 : int|float
 
$x2 : int|float
 
$y2 : int|float
 
Exceptions

Throws \InvalidArgumentException

intersect()

public Rectangle::intersect (
Rectangle $geometry
): bool

Checks whether the geometry shape intersect this rectangle.

Parameters
$geometry : Rectangle
 
Exceptions

Throws \InvalidArgumentException

scale()

public Rectangle::scale (
float $by
): Rectangle

Scale the rectangle by a value into all directions.

Parameters
$by : float
 

scaleX()

public Rectangle::scaleX (
float $by
): Rectangle

Scales the rectangle by a value on the x direction.

Parameters
$by : float
 

scaleY()

public Rectangle::scaleY (
float $by
): Rectangle

Scales the rectangle by a value on the y direction.

Parameters
$by : float
 

setDimensions()

public Rectangle::setDimensions (
int|float $width,
int|float $height
): void

Set the width and the height of the rectangle.

The lower left point couldn't be moved by this method.

Parameters
$width : int|float
 
$height : int|float
 
Exceptions

Throws \InvalidArgumentException

setHeight()

public Rectangle::setHeight (
int|float $height
): void

Set the height of the rectangle.

The lower left point couldn't be moved by this method.

Parameters
$height : int|float
 
Exceptions

Throws \InvalidArgumentException

setLl()

public Rectangle::setLl (
int|float|Point $a,
int|float $b = null
): void

Set the lower left point of the rectangle.

If you don't move this point over the x of the lower right or the y of the upper left this point stay the lower left.

If you move this point over only one of them, this point will replace them and the other point will be lower left.

If you move this point over both(x and y), this point will be the new upper right and upper right the new lower left.

Parameters
$a : int|float|Point
 
$b : int|float
 

setLr()

public Rectangle::setLr (
int|float|Point $a,
int|float $b = null
): void

Set the lower right point of the rectangle.

Parameters
$a : int|float|Point
 
$b : int|float
 
See

setUl()

public Rectangle::setUl (
int|float|Point $a,
int|float $b = null
): void

Set the upper left point of the rectangle.

Parameters
$a : int|float|Point
 
$b : int|float
 
See

setUr()

public Rectangle::setUr (
int|float|Point $a,
int|float $b = null
): void

Set the upper right point of the rectangle.

Parameters
$a : int|float|Point
 
$b : int|float
 
See

setWidth()

public Rectangle::setWidth (
int|float $width
): void

Set the width of the rectangle.

The lower left point couldn't be moved by this method.

Parameters
$width : int|float
 
Exceptions

Throws \InvalidArgumentException