public
|
setFont(object $font)
Sets the active font. Can be an instance of
\WideImage\Font\TTF, \WideImage\Font\PS, or \WideImage\Font\GDF.
Sets the active font. Can be an instance of
\WideImage\Font\TTF, \WideImage\Font\PS, or \WideImage\Font\GDF.
Parameters
$font |
Font object to set for writeText()
|
|
#
|
public
|
useFont(string $file, int $size = 12, int $color = 0, int $bgcolor = null): mixed
Creates and sets the current font
Creates and sets the current font
The supported font types are: TTF/OTF, PS, and GDF.
Font type is detected from the extension. If the $file parameter doesn't have an extension, TTF font is presumed.
Note: not all parameters are supported by all fonts.
Parameters
$file |
Font file name (string)
|
$size |
Font size (supported for TTF/OTF and PS fonts, ignored for GDF)
|
$color |
Text color
|
$bgcolor |
Background color (supported only for PS font, ignored for TTF and PS)
|
Returns
One of the \WideImage\Font* objects
|
#
|
public
|
writeText(int $x, int $y, string $text, int $angle = 0)
Write text on the image at specified position
Write text on the image at specified position
You must set a font with a call to \WideImage\Canvas::setFont() prior to writing text to the image.
Smart coordinates are supported for $x and $y arguments, but currently only for TTF/OTF fonts.
Example:
$img = WideImage::load('pic.jpg');
$canvas = $img->getCanvas();
$canvas->useFont('Verdana.ttf', 16, $img->allocateColor(255, 0, 0));
$canvas->writeText('right', 'bottom', 'www.website.com');
Parameters
$x |
Left
|
$y |
Top
|
$text |
Text to write
|
$angle |
The angle, defaults to 0
|
|
#
|
public
|
__call($method, $params)
A magic method that allows you to call any PHP function that starts with "image".
A magic method that allows you to call any PHP function that starts with "image".
This is a shortcut to call custom functions on the image handle.
Example:
$img = WideImage::load('pic.jpg');
$canvas = $img->getCanvas();
$canvas->filledRect(10, 10, 20, 30, $img->allocateColor(0, 0, 0));
$canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0));
|
#
|