API - XOOPS 2.5.11 Beta 2
By monxoops.fr
Canvas Class Reference

Public Member Functions

 __construct ($img)
 
 setFont ($font)
 
 useFont ($file, $size=12, $color=0, $bgcolor=null)
 
 writeText ($x, $y, $text, $angle=0)
 
 __call ($method, $params)
 

Protected Attributes

 $handle = 0
 
 $image = null
 
 $font = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $img)

Creates a canvas object that writes to the image passed as a parameter

Shouldn't be used directly, use \WideImage\Image::getCanvas() instead.

Parameters
\WideImage\Image$imgImage object

Member Function Documentation

◆ __call()

__call (   $method,
  $params 
)

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

◆ setFont()

setFont (   $font)

Sets the active font. Can be an instance of \WideImage\Font\TTF, \WideImage\Font\PS, or \WideImage\Font\GDF.

Parameters
object$fontFont object to set for writeText()

◆ useFont()

useFont (   $file,
  $size = 12,
  $color = 0,
  $bgcolor = null 
)

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
string$fileFont file name (string)
int$sizeFont size (supported for TTF/OTF and PS fonts, ignored for GDF)
int$colorText color
int$bgcolorBackground color (supported only for PS font, ignored for TTF and PS)
Returns
mixed One of the \WideImage\Font* objects

◆ writeText()

writeText (   $x,
  $y,
  $text,
  $angle = 0 
)

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
int$xLeft
int$yTop
string$textText to write
int$angleThe angle, defaults to 0

Field Documentation

◆ $font

$font = null
protected

◆ $handle

$handle = 0
protected

◆ $image

$image = null
protected

The documentation for this class was generated from the following file: