\GrafikaPosition

Hold and computes position of objects added to canvas.

Summary

Methods
Properties
Constants
__construct()
getXY()
getText()
getOffsetY()
getOffsetX()
No public properties found
TOP_LEFT
TOP_CENTER
TOP_RIGHT
CENTER_LEFT
CENTER
CENTER_RIGHT
BOTTOM_LEFT
BOTTOM_CENTER
BOTTOM_RIGHT
No protected methods found
No protected properties found
N/A
No private methods found
$position
$offsetX
$offsetY
N/A

Constants

TOP_LEFT

TOP_LEFT = 'top-left'

Top left of the canvas.

TOP_CENTER

TOP_CENTER = 'top-center'

Top center of the canvas.

TOP_RIGHT

TOP_RIGHT = 'top-right'

Top right of the canvas.

CENTER_LEFT

CENTER_LEFT = 'center-left'

Center left of the canvas.

CENTER

CENTER = 'center'

Center of the canvas.

CENTER_RIGHT

CENTER_RIGHT = 'center-right'

Center right of the canvas.

BOTTOM_LEFT

BOTTOM_LEFT = 'bottom-left'

Center left of the canvas.

BOTTOM_CENTER

BOTTOM_CENTER = 'bottom-center'

Bottom center of the canvas.

BOTTOM_RIGHT

BOTTOM_RIGHT = 'bottom-right'

Bottom right of the canvas.

Properties

$position

$position : string

Type

string — Holds position in human-readable text.

$offsetX

$offsetX : integer

Type

integer — Number of pixels to the left of the origin

$offsetY

$offsetY : integer

Type

integer — Number of pixels to the bottom of the origin.

Methods

__construct()

__construct(string  $position = 'center', integer  $offsetX, integer  $offsetY) 

Position constructor.

Parameters

string $position

Defaults to center.

integer $offsetX

Defaults to 0.

integer $offsetY

Defaults to 0.

getXY()

getXY(integer  $canvasWidth, integer  $canvasHeight, integer  $imageWidth, integer  $imageHeight) : array

Translate the textual position + offsets into x,y values.

Parameters

integer $canvasWidth

Width of canvas.

integer $canvasHeight

Height of canvas.

integer $imageWidth

Width of image/object added.

integer $imageHeight

Height of image/object added.

Throws

\Exception

When invalid position.

Returns

array —

Array of X and Y coordinates: array($x, $y).

getText()

getText() : string

Returns

string

getOffsetY()

getOffsetY() : integer

Returns

integer

getOffsetX()

getOffsetX() : integer

Returns

integer