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|\SetaPDF_Core_Geometry_Point $a,
int|float|\SetaPDF_Core_Geometry_Point $b,
int|float $c = null,
int|float $d = null
)

The constructor.

There three ways to create a rectangle:

- 2 params   \SetaPDF_Core_Geometry_Point $a  point1
             \SetaPDF_Core_Geometry_Point $b  point2

- 3 params   \SetaPDF_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|\SetaPDF_Core_Geometry_Point

point1 OR pointLL OR x of point1

$b : int|float|\SetaPDF_Core_Geometry_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()

Checks if this geometry collides with another geometry.

Parameters
$geometry : \SetaPDF_Core_Geometry_Collidable
 

contains()

Checks whether this rectangle contains another geometric object.

Parameters
$geometry : \SetaPDF_Core_Geometry_Point|\SetaPDF_Core_Geometry_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()

Returns the lower left point of the rectangle.

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

getLr()

Returns the lower right point of the rectangle.

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

getUl()

Returns the upper left point of the rectangle.

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

getUr()

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()

Checks whether the geometry shape intersect this rectangle.

Parameters
$geometry : \SetaPDF_Core_Geometry_Rectangle
 
Exceptions

Throws \InvalidArgumentException

scale()

Scale the rectangle by a value into all directions.

Parameters
$by : float
 

scaleX()

Scales the rectangle by a value on the x directon.

Parameters
$by : float
 

scaleY()

Scales the rectangle by a value on the y directon.

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|\SetaPDF_Core_Geometry_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|\SetaPDF_Core_Geometry_Point
 
$b : int|float
 

setLr()

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

Set the lower right point of the rectangle.

Parameters
$a : int|float|\SetaPDF_Core_Geometry_Point
 
$b : int|float
 
See

setUl()

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

Set the upper left point of the rectangle.

Parameters
$a : int|float|\SetaPDF_Core_Geometry_Point
 
$b : int|float
 
See

setUr()

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

Set the upper right point of the rectangle.

Parameters
$a : int|float|\SetaPDF_Core_Geometry_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