Class

Imagine\Gd\Drawer

class Drawer implements DrawerInterface

Drawer implementation using the GD library

Methods

__construct(resource $resource)

Constructs Drawer with a given gd image resource

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

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

DrawerInterface chord(PointInterface $center, BoxInterface $size, integer $start, integer $end, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

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

DrawerInterface ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

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

DrawerInterface line(PointInterface $start, PointInterface $end, ColorInterface $color, integer $thickness = 1)

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

DrawerInterface pieSlice(PointInterface $center, BoxInterface $size, integer $start, integer $end, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

Same as arc, but connects end points and the center

DrawerInterface dot(PointInterface $position, ColorInterface $color)

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

DrawerInterface polygon(array $coordinates, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

Draws a polygon using array of x, y coordinates.

DrawerInterface text(string $string, AbstractFont $font, PointInterface $position, integer $angle, integer $width = null)

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

Details

at line 43
public __construct(resource $resource)

Constructs Drawer with a given gd image resource

Parameters

resource $resource

at line 52
public DrawerInterface arc(PointInterface $center, BoxInterface $size, integer $start, integer $end, ColorInterface $color, integer $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
integer $start
integer $end
ColorInterface $color
integer $thickness

Return Value

DrawerInterface

Exceptions

RuntimeException

at line 77
public DrawerInterface chord(PointInterface $center, BoxInterface $size, integer $start, integer $end, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

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

{@inheritdoc}

Parameters

PointInterface $center
BoxInterface $size
integer $start
integer $end
ColorInterface $color
Boolean $fill
integer $thickness

Return Value

DrawerInterface

at line 106
public DrawerInterface ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, Boolean $fill = false, integer $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
Boolean $fill
integer $thickness

Return Value

DrawerInterface

Exceptions

RuntimeException

at line 135
public DrawerInterface line(PointInterface $start, PointInterface $end, ColorInterface $color, integer $thickness = 1)

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

Parameters

PointInterface $start
PointInterface $end
ColorInterface $color
integer $thickness

Return Value

DrawerInterface

at line 158
public DrawerInterface pieSlice(PointInterface $center, BoxInterface $size, integer $start, integer $end, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

Same as arc, but connects end points and the center

Parameters

PointInterface $center
BoxInterface $size
integer $start
integer $end
ColorInterface $color
Boolean $fill
integer $thickness

Return Value

DrawerInterface

Exceptions

RuntimeException

at line 187
public DrawerInterface 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

DrawerInterface

Exceptions

RuntimeException

at line 208
public DrawerInterface polygon(array $coordinates, ColorInterface $color, Boolean $fill = false, integer $thickness = 1)

Draws a polygon using array of x, y coordinates.

Must contain at least three coordinates

Parameters

array $coordinates
ColorInterface $color
Boolean $fill
integer $thickness

Return Value

DrawerInterface

Exceptions

RuntimeException

at line 245
public DrawerInterface text(string $string, AbstractFont $font, PointInterface $position, integer $angle, integer $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
integer $angle
integer $width

Return Value

DrawerInterface

Exceptions

RuntimeException