WideImage
[ class tree: WideImage ] [ index: WideImage ] [ all elements ]

Class: WideImage_Canvas

Source Location: /Canvas.php

Class Overview




Variables

Methods



Class Details

[line 43]


[ Top ]


Class Variables

$font =  null

[line 47]



Tags:

access:  protected

Type:   mixed


[ Top ]

$handle =  0

[line 45]



Tags:

access:  protected

Type:   mixed


[ Top ]

$image =  null

[line 46]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 56]

WideImage_Canvas __construct( WideImage_Image $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   $img   Image object

[ Top ]

method setFont [line 71]

void setFont( object $font)

Sets the active font. Can be an instance of WideImage_Font_TTF, WideImage_Font_PS, or WideImage_Font_GDF.



Parameters:

object   $font   Font object to set for writeText()

[ Top ]

method useFont [line 90]

mixed useFont( string $file, [int $size = 12], [int $color = 0], [int $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.




Tags:

return:  One of the WideImage_Font_* objects


Parameters:

string   $file   Font file name (string)
int   $size   Font size (supported for TTF/OTF and PS fonts, ignored for GDF)
int   $color   Text color
int   $bgcolor   Background color (supported only for PS font, ignored for TTF and PS)

[ Top ]

method writeText [line 131]

void writeText( int $x, int $y, string $text, [int $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:

  1.  $img WideImage::load('pic.jpg');
  2.  $canvas $img->getCanvas();
  3.  $canvas->useFont('Verdana.ttf'16$img->allocateColor(25500));
  4.  $canvas->writeText('right''bottom''www.website.com');




Parameters:

int   $x   Left
int   $y   Top
string   $text   Text to write
int   $angle   The angle, defaults to 0

[ Top ]

method __call [line 157]

void __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:

  1.  $img WideImage::load('pic.jpg');
  2.  $canvas $img->getCanvas();
  3.  $canvas->filledRect(10102030$img->allocateColor(000));
  4.  $canvas->line(608030100$img->allocateColor(25500));




Parameters:

   $method  
   $params  

[ Top ]


Documentation generated on Sat, 19 Feb 2011 12:55:41 +0100 by phpDocumentor 1.4.3