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

Class: Canvas

Source Location: /graphics.inc.php

Class Overview

Object
   |
   --Persistent
      |
      --Canvas

Canvas provides an abstract drawing space for objects that must render their own images.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Persistent

Persistent::allowserialize()
This method provides an opportunity for the component developer to prevent the serialization/unserialization of a property.
Persistent::assign()
Assigns the source properties to this object.
Persistent::assignError()
Raises an assignation error.
Persistent::assignTo()
Assigns this object to another object.
Persistent::inSession()
This method determines if this object exists in the current session.
Persistent::readNamePath()
Used to serialize/unserialize. It returns the full path to identify this component.
Persistent::readOwner()
Owner of the component.
Persistent::serialize()
Stores this object into the session.
Persistent::unserialize()
This method uses PHP reflection to iterate through published properties (the ones starting with get) and retrieve the properties stored by a previous serialize() call.

Class: Object

Object::__construct()
Constructs an object and initializes its data before the object is first used.
Object::className()
Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
Object::classNameIs()
Determines whether an object is of a specific type.
Object::classParent()
Returns the type of the immediate ancestor of a class.
Object::inheritsFrom()
Determines the relationship of two object types.
Object::methodExists()
Check if a method exists declared on this object instance.
Object::readProperty()
Reads a property from the streams
Object::__get()
To virtualize properties
Object::__set()
To virtualize properties

Class Details

[line 1265]
Canvas provides an abstract drawing space for objects that must render their own images.

Use Canvas as a drawing surface for objects that draw an image of themselves. Standard controls such as edit controls or list boxes do not require a canvas, as they are drawn by the browser, but Graphic controls can use a canvas to generate an image in run-time

Canvas provides properties, events and methods that assist in creating an image by

Specifying the type of brush, pen and font to use.

Drawing and filling a variety of shapes and lines.

Writing text.

Rendering graphic images.

  1.  <?php
  2.    function PaintBox1Paint($sender$params)
  3.    {
  4.     $this->PaintBox1->Canvas->Pen->Color="#FF0000";
  5.     $this->PaintBox1->Canvas->Line(0,0,100,100);
  6.  
  7.     $this->PaintBox1->Canvas->Brush->Color="#00FF00";
  8.     $this->PaintBox1->Canvas->Rectangle(100,100,200,200);
  9.  
  10.     $this->PaintBox1->Canvas->TextOut(50,50"VCL for PHP Canvas");
  11.    }
  12.  ?>




Tags:

see:  Pen, Brush
example:  example not found


[ Top ]


Class Variables

$_brush = null

[line 1268]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_canvas = ""

[line 1270]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_font = null

[line 1269]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_object = ""

[line 1271]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_owner = null

[line 1272]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_pen = null

[line 1267]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 1274]

Canvas __construct( [ $aowner = null])



Overrides Object::__construct() (Constructs an object and initializes its data before the object is first used.)

Parameters:

   $aowner  

[ Top ]

method arc [line 1412]

void arc( int $x1, int $y1, int $x2, int $y2, int $x3, int $y3, int $x4, int $y4)

Draws an arc on the image along the perimeter of the ellipse bounded by the specified rectangle.

Use Arc to draw an elliptically curved line with the current Pen. The arc traverses the perimeter of an ellipse that is bounded by the points (X1,Y1) and (X2,Y2).

The arc is drawn following the perimeter of the ellipse, counterclockwise, from the starting point to the ending point. The starting point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X3,Y3). The ending point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X4, Y4).




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates
int   $x3   The left intersection at pixel coordinates
int   $y3   The top intersection at pixel coordinates
int   $x4   The right intersection at pixel coordinates
int   $y4   The bottom intersection at pixel coordinates

[ Top ]

method beginDraw [line 1368]

void beginDraw( )

Begins draw cycle.

In VCL for PHP, graphics are drawn on the browser using javascript, and this method is needed to dump the required code to initialize drawing objects and to establishes internal Canvas object.

Should be followed by EndDraw to push drawing to the page canvas.




[ Top ]

method bevelLine [line 1677]

void bevelLine( $color, $x1, $y1, $x2, $y2)

Draw the line using specified color



Parameters:

   $color  
   $x1  
   $y1  
   $x2  
   $y2  

[ Top ]

method bevelRect [line 1664]

void bevelRect( $x1, $y1, $x2, $y2, $color1, $color2)

Draw Bevel-like rectangle using specified colors



Parameters:

   $x1  
   $y1  
   $x2  
   $y2  
   $color1  
   $color2  

[ Top ]

method clear [line 1688]

void clear( )

Clears the canvas

Use this method to erase all the drawings in the canvas




[ Top ]

method ellipse [line 1432]

void ellipse( int $x1, int $y1, int $x2, int $y2)

Draws the ellipse defined by a bounding rectangle on the canvas.

Call Ellipse to draw a circle or ellipse on the canvas. Specify the bounding rectangle by giving the top left point at pixel coordinates (X1, Y1) and the bottom right point at (X2, Y2).

If the bounding rectangle is a square, a circle is drawn.

The ellipse is outlined using the value of Pen, and filled using the value of Brush.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates

[ Top ]

method endDraw [line 1383]

void endDraw( )

Ends draw cycle.

In VCL for PHP, graphics are drawn on the browser using javascript, and this method is needed to dump the required code to finalize drawing and to flush out all drawing commands.




[ Top ]

method fillRect [line 1450]

void fillRect( int $x1, int $y1, int $x2, int $y2)

Fills the specified rectangle on the canvas using the current brush.

Use FillRect to fill a rectangular region using the current brush. The region is filled including the top and left sides of the rectangle, but excluding the bottom and right edges.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates

[ Top ]

method forceBrush [line 1292]

void forceBrush( )

Intermal method

This method is used to set the color for the canvas to the brush color if the brush has been modified.




Tags:

access:  protected


[ Top ]

method forceFont [line 1325]

void forceFont( )

Intermal method

This method is used to set the font for the canvas to the font property




Tags:

access:  protected


[ Top ]

method forcePen [line 1308]

void forcePen( )

Intermal method

This method is used to set the stroke color for the canvas to the pen color if the pen has been modified.




Tags:

access:  protected


[ Top ]

method frameRect [line 1469]

void frameRect( int $x1, int $y1, int $x2, int $y2)

Draws a rectangle using the Brush of the canvas to draw the border.

Use FrameRect to draw a 1 pixel wide border around a rectangular region. FrameRect does not fill the interior of the rectangle with the Brush pattern.

To draw a boundary using the Pen instead, use the Polygon method.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates

[ Top ]

method getBrush [line 1716]

Brush getBrush( )

Determines the color and pattern for filling graphical shapes and backgrounds.

Set the Brush property to specify the color and pattern to use when drawing the background or filling in graphical shapes. The value of Brush is a Brush object. Set the properties of the Brush object to specify the color and pattern or bitmap to use when filling in spaces on the canvas.

Note: Setting the Brush property replaces the specified Brush object, rather than copying the current Brush object.




[ Top ]

method getFont [line 1730]

Font getFont( )

Specifies the font to use when writing text on the image.

Set Font to specify the font to use for writing text on the image. The value of Font is a Font object. Set the properties of the Font object to specify the font face, color, size, style, and any other aspects of the font.

Note: Setting the Font property replaces the specified Font object, rather than copying the current Font object.




[ Top ]

method getPen [line 1743]

Pen getPen( )

Specifies the kind of pen the canvas uses for drawing lines and outlining shapes.

Set Pen to specify the pen to use for drawing lines and outlining shapes in the image. The value of Pen is a Pen object. Set the properties of the Pen object to specify the color, style, width, and mode of the pen.

Note: Setting the Pen property replaces the specified Pen object, rather than copying the current Pen object.




[ Top ]

method initLibrary [line 1335]

void initLibrary( )

This method dumps the .js required to initiate graphic library



[ Top ]

method line [line 1486]

void line( int $x1, int $y1, int $x2, int $y2)

Draws a line on the canvas using specified coordinates

Use Line to draw a 1 pixel wide line from a point (x1,y2) to another point (x2,y2) using the current Pen




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates

[ Top ]

method paint [line 1699]

void paint( )

Paints the canvas

After drawing this does the actual painting of the canvas. Only needed when drawing from JavaScript events or from outside this canvas owner OnPaint event.




[ Top ]

method polygon [line 1502]

void polygon( array $points)

Draws a series of lines on the canvas connecting the points passed in and closing the shape by drawing a line from the last point to the first point.

Use Polygon to draw a closed, many-sided shape on the canvas, using the value of Pen. After drawing the complete shape, Polygon fills the shape using the value of Brush.

The Points parameter is an array of points that give the vertices of the polygon.




Parameters:

array   $points   An array of x, y interleaved coordinates

[ Top ]

method polyline [line 1533]

void polyline( array $points)

Draws a series of lines on the canvas with the current pen, connecting each of the points passed to it in Points.

Use Polyline to connect a set of points on the canvas. If you specify only two points, Polyline draws a single line.

The Points parameter is an array of points to be connected.




Parameters:

array   $points   An array of x, y interleaved coordinates

[ Top ]

method rectangle [line 1569]

void rectangle( int $x1, int $y1, int $x2, int $y2)

Draws a rectangle on the canvas.

Use Rectangle to draw a rectangle using Pen and fill it with Brush. Specify the rectangle’s coordinates giving four coordinates that define the upper left corner at the point (X1, Y1) and the lower right corner at the point (X2, Y2).

To fill a rectangular region without drawing the boundary in the current pen, use FillRect. To outline a rectangular region without filling it, use FrameRect or Polygon. To draw a rectangle with rounded corners, use RoundRect.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates

[ Top ]

method roundRect [line 1593]

void roundRect( int $x1, int $y1, int $x2, int $y2, int $w, int $h)

Draws a rectangle with rounded corners on the canvas.

Use RoundRect to draw a rounded rectangle using Pen and fill it with Brush. The rectangle will have edges defined by the points (X1,Y1), (X2,Y1), (X2,Y2), (X1,Y2), but the corners will be shaved to create a rounded appearance. The curve of the rounded corners matches the curvature of an ellipse with width W and height H.

To draw an ellipse instead, use Ellipse. To draw a true rectangle, use Rectangle.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates
int   $w   Width of the ellipse for rounded corners
int   $h   Height of the ellipse for rounded corners

[ Top ]

method setBrush [line 1717]

void setBrush( $value)



Parameters:

   $value  

[ Top ]

method setCanvasProperties [line 1354]

void setCanvasProperties( $Name)



Parameters:

   $Name  

[ Top ]

method setFont [line 1731]

void setFont( $value)



Parameters:

   $value  

[ Top ]

method setPen [line 1744]

void setPen( $value)



Parameters:

   $value  

[ Top ]

method stretchDraw [line 1642]

void stretchDraw( int $x1, int $y1, int $x2, int $y2, string $image)

Draws the graphic specified by the image parameter in the rectangle specified by the coordinates.

Call StretchDraw to draw a graphic on the canvas so that the image fits in the specified rectangle. This may involve changing magnification and/or aspect ratio.




Parameters:

int   $x1   The left point at pixel coordinates
int   $y1   The top point at pixel coordinates
int   $x2   The right point at pixel coordinates
int   $y2   The bottom point at pixel coordinates
string   $image   URL to the image to draw

[ Top ]

method textOut [line 1656]

void textOut( int $x, int $y, string $text)

Writes a string on the canvas, starting at the point (X,Y)

Use TextOut to write a string onto the canvas. The string will be written using the current value of Font.




Parameters:

int   $x   The left point at pixel coordinates
int   $y   The top point at pixel coordinates
string   $text   Text to write to the canvas

[ Top ]


Documentation generated on Sat, 13 Jun 2009 10:51:43 -0700 by phpDocumentor 1.4.1