[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/Canvas/ -> GD.php (sommaire)

Image_Canvas Class for handling output in GD compatible format.

Author: Jesper Veggerby <pear.nosey@veggerby.dk>
Copyright: Copyright (C) 2003, 2004 Jesper Veggerby Hansen
License: http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
Version: CVS: $Id: GD.php,v 1.11 2006/02/13 20:53:20 nosey Exp $
Poids: 1693 lignes (61 kb)
Inclus ou requis: 2 fois
Référencé: 0 fois
Nécessite: 3 fichiers
 Image/Canvas/Tool.php
 Image/Canvas/WithMap.php
 Image/Canvas/Color.php

Définit 1 class

Image_Canvas_GD:: (25 méthodes):
  Image_Canvas_GD()
  _getGD()
  _color()
  _getLineStyle()
  _getFillStyle()
  setFillImage()
  setFont()
  _linePixels()
  _antialiasedLine()
  _antialiasedPixel()
  _antialisedSubPixel()
  drawEnd()
  line()
  polygon()
  rectangle()
  ellipse()
  pieslice()
  textWidth()
  textHeight()
  addText()
  image()
  setClipping()
  toHtml()
  _reset()
  _version()


Classe: Image_Canvas_GD  - X-Ref

Canvas class to output using PHP GD support.

Image_Canvas_GD($param)   X-Ref
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 &amp;)

'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.)

param: array $param Parameter array

_getGD($filename)   X-Ref
Get an GD image resource from a file

param: string $filename
return: mixed The GD image resource

_color($color = false)   X-Ref
Get the color index for the RGB color

param: int $color The color
return: int The GD image index of the color

_getLineStyle($lineStyle = false)   X-Ref
Get the GD applicable linestyle

param: mixed $lineStyle The line style to return, false if the one
return: mixed A GD compatible linestyle

_getFillStyle($fillStyle = false, $x0 = 0, $y0 = 0, $x1 = 0, $y1 = 0)   X-Ref
Get the GD applicable fillstyle

param: mixed $fillStyle The fillstyle to return, false if the one
return: mixed A GD compatible fillstyle

setFillImage($filename)   X-Ref
Sets an image that should be used for filling

param: string $filename The filename of the image to fill with

setFont($fontOptions)   X-Ref
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

param: array $font The font options.

_linePixels($x0, $y0, $x1, $y1)   X-Ref
Calculate pixels on a line

param: int $x0 X start point
param: int $y0 X start point
param: int $x1 X end point
param: int $y1 Y end point
return: array An associated array of x,y points with all pixels on the

_antialiasedLine($x0, $y0, $x1, $y1, $color = false)   X-Ref
Draws an antialiased line

param: int $x0 X start point
param: int $y0 X start point
param: int $x1 X end point
param: int $y1 Y end point
param: mixed $color The line color, can be omitted

_antialiasedPixel($x, $y, $color)   X-Ref
Draws an antialiased pixel

param: int $x X point
param: int $y Y point
param: mixed $color The pixel color

_antialisedSubPixel($x, $y, $a, $b, $color)   X-Ref
Antialias'es the pixel around x,y with weights a,b

param: int $x X point
param: int $y Y point
param: int $a The weight of the current color
param: int $b The weight of the applied/wanted color
param: mixed $color The pixel color

drawEnd($params)   X-Ref
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

param: array $params Parameter array

line($params)   X-Ref
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

param: array $params Parameter array

polygon($params)   X-Ref
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
param: array $params Parameter array

rectangle($params)   X-Ref
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

param: array $params Parameter array

ellipse($params)   X-Ref
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

param: array $params Parameter array

pieslice($params)   X-Ref
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

param: array $params Parameter array

textWidth($text)   X-Ref
Get the width of a text,

param: string $text The text to get the width of
return: int The width of the text

textHeight($text, $force = false)   X-Ref
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.

param: string $text The text to get the height of
param: bool $force Force the method to calculate the size
return: int The height of the text

addText($params)   X-Ref
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

image($params)   X-Ref
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

setClipping($params = false)   X-Ref
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

toHtml($params)   X-Ref
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

_reset()   X-Ref
Resets the canvas.

Include fillstyle, linestyle, thickness and polygon

_version()   X-Ref
Check which version of GD is installed

return: int 0 if GD isn't installed, 1 if GD 1.x is installed and 2 if GD



Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7