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

Class: Image_Canvas_GD

Source Location: /Image_Canvas-0.3.5/Image/Canvas/GD.php

Class Overview

Image_Canvas
   |
   --Image_Canvas_WithMap
      |
      --Image_Canvas_GD

Canvas class to output using PHP GD support.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2003-2009 The PHP Group

Methods


Child classes:

Image_Canvas_GD_PNG
PNG Canvas class.
Image_Canvas_GD_JPG
JPEG Canvas class.

Inherited Variables

Inherited Methods

Class: Image_Canvas_WithMap

Image_Canvas_WithMap::Image_Canvas_WithMap()
Create the canvas.
Image_Canvas_WithMap::addSpline()
Adds "splined" vertex to a polygon
Image_Canvas_WithMap::addText()
Writes text
Image_Canvas_WithMap::addVertex()
Adds vertex to a polygon
Image_Canvas_WithMap::ellipse()
Draw an ellipse
Image_Canvas_WithMap::getImageMap()
Get the imagemap
Image_Canvas_WithMap::image()
Overlay image
Image_Canvas_WithMap::line()
Draw a line
Image_Canvas_WithMap::pieslice()
Draw a pie slice
Image_Canvas_WithMap::polygon()
Draws a polygon
Image_Canvas_WithMap::rectangle()
Draw a rectangle

Class: Image_Canvas

Image_Canvas::Image_Canvas()
Create the canvas.
Image_Canvas::addSpline()
Adds "splined" vertex to a polygon
Image_Canvas::addText()
Writes text
Image_Canvas::addVertex()
Adds vertex to a polygon
Image_Canvas::drawEnd()
Draw a line end
Image_Canvas::ellipse()
Draw an ellipse
Image_Canvas::endGroup()
End the "current" group.
Image_Canvas::factory()
Canvas factory method.
Image_Canvas::getHeight()
Get the height of the canvas
Image_Canvas::getWidth()
Get the width of the canvas
Image_Canvas::image()
Overlay image
Image_Canvas::line()
Draw a line
Image_Canvas::pieslice()
Draw a pie slice
Image_Canvas::polygon()
Draws a polygon
Image_Canvas::rectangle()
Draw a rectangle
Image_Canvas::reset()
Reset the canvas.
Image_Canvas::save()
Save the result of the canvas to a file
Image_Canvas::setClipping()
Set clipping to occur
Image_Canvas::setDefaultFont()
Sets the default font options.
Image_Canvas::setFill()
Sets the style of the filling of drawn objects.
Image_Canvas::setFillColor()
Sets the color of the filling of drawn objects
Image_Canvas::setFillImage()
Sets an image that should be used for filling
Image_Canvas::setFont()
Sets the font options.
Image_Canvas::setGradientFill()
Sets a gradient fill
Image_Canvas::setLineColor()
Sets the color of the line(s) to be drawn
Image_Canvas::setLineThickness()
Sets the thickness of the line(s) to be drawn
Image_Canvas::show()
Output the result of the canvas to the browser
Image_Canvas::startGroup()
Start a group.
Image_Canvas::textHeight()
Get the height of a text,
Image_Canvas::textWidth()
Get the width of a text,
Image_Canvas::toHtml()
Get a canvas specific HTML tag.

Class Details

[line 59]
Canvas class to output using PHP GD support.


[ Top ]


Method Detail

Image_Canvas_GD (Constructor)   [line 154]

Image_Canvas_GD Image_Canvas_GD( array $param)

Create the GD canvas.

Parameters available:

'width' The width of the graph on the canvas

'height' The height of the graph on the canvas

'left' The left offset of the graph on the canvas

'top' The top offset of the graph on the canvas

'antialias' = 'native' enables native GD antialiasing - this method has no severe impact on performance (approx +5%). Requires PHP 4.3.2 (with bundled GD2)

'antialias' = {true|'driver'} Image_Graph implemented method. This method has a severe impact on performance, drawing an antialiased line this way is about XX times slower, with an overall performance impact of about +40%. The justification for this method is that if native support is not available this can be used, it is also a future feature that this method for antialiasing will support line styles.

Use antialiased for best results with a line/area chart having just a few datapoints. Native antialiasing does not provide a good appearance with short lines, as for example with smoothed charts. Antialiasing does not (currently) work with linestyles, neither native nor driver method!

'noalpha' = true If alpha blending is to be disabled

'filename' An image to open, on which the graph is created on

'gd' A GD resource to add the image to, use this option to continue working on an already existing GD resource. Make sure this is passed 'by- reference' (using &)

'usemap' Initialize an image map

'gd' and 'filename' are mutually exclusive with 'gd' as preference

'width' and 'height' are required unless 'filename' or 'gd' are specified, in which case the width and height are taken as the actual image width/height. If the latter is the case and 'left' and/or 'top' was also specified, the actual 'width'/'height' are altered so that the graph fits inside the canvas (i.e 'height' = actual height - top, etc.)


Parameters:

array   $param     Parameter array

[ Top ]

addText   [line 1517]

void addText( array $params)

Writes text

Parameter array:

'x': int X-point of text

'y': int Y-point of text

'text': string The text to add

'alignment': array [optional] Alignment

'color': mixed [optional] The color of the text


Overrides Image_Canvas_WithMap::addText() (Writes text)

Parameters:

array   $params     Parameter array

[ Top ]

drawEnd   [line 793]

void drawEnd( array $params)

Draw a line end

Parameter array:

'x': int X point

'y': int Y point

'end': string The end type of the end

'size': int The size of the end

'color': string The color of the end

'angle': int [optional] The angle with which to draw the end


Overrides Image_Canvas::drawEnd() (Draw a line end)

Parameters:

array   $params     Parameter array

[ Top ]

ellipse   [line 1197]

void ellipse( array $params)

Draw an ellipse

Parameter array:

'x': int X center point

'y': int Y center point

'rx': int X radius

'ry': int Y radius

'fill': mixed [optional] The fill color

'line': mixed [optional] The line color


Overrides Image_Canvas_WithMap::ellipse() (Draw an ellipse)

Parameters:

array   $params     Parameter array

[ Top ]

image   [line 1627]

void image( array $params)

Overlay image

Parameter array:

'x': int X-point of overlayed image

'y': int Y-point of overlayed image

'filename': string The filename of the image to overlay

'width': int [optional] The width of the overlayed image (resizing if possible)

'height': int [optional] The height of the overlayed image (resizing if possible)

'alignment': array [optional] Alignment


Overrides Image_Canvas_WithMap::image() (Overlay image)

Parameters:

array   $params     Parameter array

[ Top ]

line   [line 908]

void line( array $params)

Draw a line

Parameter array:

'x0': int X start point

'y0': int Y start point

'x1': int X end point

'y1': int Y end point

'color': mixed [optional] The line color


Overrides Image_Canvas_WithMap::line() (Draw a line)

Parameters:

array   $params     Parameter array

[ Top ]

pieslice   [line 1245]

void pieslice( array $params)

Draw a pie slice

Parameter array:

'x': int X center point

'y': int Y center point

'rx': int X radius

'ry': int Y radius

'v1': int The starting angle (in degrees)

'v2': int The end angle (in degrees)

'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)

'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)

'fill': mixed [optional] The fill color

'line': mixed [optional] The line color


Overrides Image_Canvas_WithMap::pieslice() (Draw a pie slice)

Parameters:

array   $params     Parameter array

[ Top ]

polygon   [line 956]

void polygon( array $params)

Parameter array:

'connect': bool [optional] Specifies whether the start point should be connected to the endpoint (closed polygon) or not (connected line)

'fill': mixed [optional] The fill color

'line': mixed [optional] The line color


Overrides Image_Canvas_WithMap::polygon() (Draws a polygon)

Parameters:

array   $params     Parameter array

[ Top ]

rectangle   [line 1156]

void rectangle( array $params)

Draw a rectangle

Parameter array:

'x0': int X start point

'y0': int Y start point

'x1': int X end point

'y1': int Y end point

'fill': mixed [optional] The fill color

'line': mixed [optional] The line color


Overrides Image_Canvas_WithMap::rectangle() (Draw a rectangle)

Parameters:

array   $params     Parameter array

[ Top ]

setClipping   [line 1736]

void setClipping( [array $params = false])

Set clipping to occur

Parameter array:

'x0': int X point of Upper-left corner 'y0': int X point of Upper-left corner 'x1': int X point of lower-right corner 'y1': int Y point of lower-right corner


Overrides Image_Canvas::setClipping() (Set clipping to occur)

Parameters:

array   $params     Parameter array

[ Top ]

setFillImage   [line 592]

void setFillImage( string $filename)

Sets an image that should be used for filling

Overrides Image_Canvas::setFillImage() (Sets an image that should be used for filling)

Parameters:

string   $filename     The filename of the image to fill with

[ Top ]

setFont   [line 613]

void setFont( array $fontOptions)

Sets the font options.

The $font array may have the following entries:

'ttf' = the .ttf file (either the basename, filename or full path) If 'ttf' is specified, then the following can be specified

'size' = size in pixels

'angle' = the angle with which to write the text


Overrides Image_Canvas::setFont() (Sets the font options.)

Parameters:

array   $fontOptions     The font options.

[ Top ]

textHeight   [line 1360]

int textHeight( string $text, [bool $force = false])

Get the height of a text.

Note! This method can give some peculiar results, since ImageTTFBBox() returns the total bounding box of a text, where ImageTTF() writes the text on the baseline of the text, that is 'g', 'p', 'q' and other letters that dig under the baseline will appear to have a larger height than they actually do. Have a look at the tests/text.php test case - the first two columns, 'left and 'center', both look alright, whereas the last column, 'right', appear with a larger space between the first text and the second. This is because the total height is actually smaller by exactly the number of pixels that the 'g' digs under the baseline. Remove the 'g' from the text and they appear correct.

  • Return: The height of the text

Overrides Image_Canvas::textHeight() (Get the height of a text,)

Parameters:

string   $text     The text to get the height of
bool   $force     Force the method to calculate the size

[ Top ]

textWidth   [line 1306]

int textWidth( string $text)

Get the width of a text,
  • Return: The width of the text

Overrides Image_Canvas::textWidth() (Get the width of a text,)

Parameters:

string   $text     The text to get the width of

[ Top ]

toHtml   [line 1805]

string toHtml( array $params)

Get a canvas specific HTML tag.

This method implicitly saves the canvas to the filename in the filesystem path specified and parses it as URL specified by URL path

Parameter array:

'filename' string

'filepath': string Path to the file on the file system. Remember the final slash

'urlpath': string Path to the file available through an URL. Remember the final slash

'alt': string [optional] Alternative text on image

'cssclass': string [optional] The CSS Stylesheet class

'border': int [optional] The border width on the image

  • Return: HTML code

Overrides Image_Canvas::toHtml() (Get a canvas specific HTML tag.)

Parameters:

array   $params     Parameter array

[ Top ]


Documentation generated on Fri, 27 Jul 2012 07:30:08 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.