class Drawer implements DrawerInterface

Drawer implementation using the GD PHP extension.

Methods

__construct(resource|GdImage $resource)

Constructs Drawer with a given gd image resource.

$this
arc(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, int $thickness = 1)

Draws an arc on a starting at a given x, y coordinates under a given start and end angles.

$this
chord(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, bool $fill = false, int $thickness = 1)

This function does not work properly because of a bug in GD.

$this
circle(PointInterface $center, int $radius, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws and circle with center at the given x, y coordinates, and given radius.

$this
ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws and ellipse with center at the given x, y coordinates, and given width and height.

$this
line(PointInterface $start, PointInterface $end, ColorInterface $color, int $thickness = 1)

Draws a line from start(x, y) to end(x, y) coordinates.

$this
pieSlice(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, bool $fill = false, int $thickness = 1)

Same as arc, but connects end points and the center.

$this
dot(PointInterface $position, ColorInterface $color)

Places a one pixel point at specific coordinates and fills it with specified color.

$this
rectangle(PointInterface $leftTop, PointInterface $rightBottom, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws a rectangle from left, top(x, y) to right, bottom(x, y) coordinates.

$this
polygon(array $coordinates, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws a polygon using array of x, y coordinates. Must contain at least three coordinates.

$this
text(string $string, AbstractFont $font, PointInterface $position, int $angle = 0, int $width = null)

Annotates image with specified text at a given position starting on the top left of the final text box.

Details

at line 44
__construct(resource|GdImage $resource)

Constructs Drawer with a given gd image resource.

Parameters

resource|GdImage $resource

at line 55
$this arc(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, int $thickness = 1)

Draws an arc on a starting at a given x, y coordinates under a given start and end angles.

Parameters

PointInterface $center
BoxInterface $size
int $start
int $end
ColorInterface $color
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::arc

at line 86
$this chord(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, bool $fill = false, int $thickness = 1)

This function does not work properly because of a bug in GD.

{@inheritdoc}

Parameters

PointInterface $center
BoxInterface $size
int $start
int $end
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

See also

DrawerInterface::chord

at line 125
$this circle(PointInterface $center, int $radius, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws and circle with center at the given x, y coordinates, and given radius.

Parameters

PointInterface $center
int $radius
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::circle

at line 137
$this ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws and ellipse with center at the given x, y coordinates, and given width and height.

Parameters

PointInterface $center
BoxInterface $size
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::ellipse

at line 181
$this line(PointInterface $start, PointInterface $end, ColorInterface $color, int $thickness = 1)

Draws a line from start(x, y) to end(x, y) coordinates.

Parameters

PointInterface $start
PointInterface $end
ColorInterface $color
int $thickness

Return Value

$this

See also

DrawerInterface::line

at line 210
$this pieSlice(PointInterface $center, BoxInterface $size, int $start, int $end, ColorInterface $color, bool $fill = false, int $thickness = 1)

Same as arc, but connects end points and the center.

Parameters

PointInterface $center
BoxInterface $size
int $start
int $end
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::pieSlice

at line 245
$this dot(PointInterface $position, ColorInterface $color)

Places a one pixel point at specific coordinates and fills it with specified color.

Parameters

PointInterface $position
ColorInterface $color

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::dot

at line 268
$this rectangle(PointInterface $leftTop, PointInterface $rightBottom, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws a rectangle from left, top(x, y) to right, bottom(x, y) coordinates.

Parameters

PointInterface $leftTop
PointInterface $rightBottom
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::rectangle

at line 308
$this polygon(array $coordinates, ColorInterface $color, bool $fill = false, int $thickness = 1)

Draws a polygon using array of x, y coordinates. Must contain at least three coordinates.

Parameters

array $coordinates
ColorInterface $color
bool $fill
int $thickness

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::polygon

at line 351
$this text(string $string, AbstractFont $font, PointInterface $position, int $angle = 0, int $width = null)

Annotates image with specified text at a given position starting on the top left of the final text box.

The rotation is done CW

Parameters

string $string
AbstractFont $font
PointInterface $position
int $angle
int $width

Return Value

$this

Exceptions

RuntimeException

See also

DrawerInterface::text