Object | --Persistent | --Canvas
Located in File: /graphics.inc.php
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.
![]() | Brush | Determines the color and pattern for filling graphical shapes and backgrounds. |
![]() | Pen | Specifies the kind of pen the canvas uses for drawing lines and outlining shapes. |
Defined in class Persistent |
||
![]() | NamePath | Used to serialize/unserialize. It returns the full path to identify this component. |
![]() | Owner | Owner of the component. |
property Brush (line 1716)
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.
property Pen (line 1743)
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.
property NamePath
| __construct | Constructs an object and initializes its data before the object is first used. [Overrides Object::__construct()] |
| arc | Draws an arc on the image along the perimeter of the ellipse bounded by the specified rectangle. |
| beginDraw | Begins draw cycle. |
| bevelLine | Draw the line using specified color |
| bevelRect | Draw Bevel-like rectangle using specified colors |
| clear | Clears the canvas |
| ellipse | Draws the ellipse defined by a bounding rectangle on the canvas. |
| endDraw | Ends draw cycle. |
| fillRect | Fills the specified rectangle on the canvas using the current brush. |
| forceBrush | Intermal method |
| forceFont | Intermal method |
| forcePen | Intermal method |
| frameRect | Draws a rectangle using the Brush of the canvas to draw the border. |
| initLibrary | This method dumps the .js required to initiate graphic library |
| line | Draws a line on the canvas using specified coordinates |
| paint | Paints the canvas |
| polygon | 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. |
| polyline | Draws a series of lines on the canvas with the current pen, connecting each of the points passed to it in Points. |
| rectangle | Draws a rectangle on the canvas. |
| roundRect | Draws a rectangle with rounded corners on the canvas. |
| stretchDraw | Draws the graphic specified by the image parameter in the rectangle specified by the coordinates. |
| textOut | Writes a string on the canvas, starting at the point (X,Y) |
Defined in class Persistent |
||
![]() | serialize | Stores this object into the session. |
![]() | 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. |
Defined in class Object |
||
![]() | __construct | Constructs an object and initializes its data before the object is first used. |
![]() | className | Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument). |
![]() | classParent | Returns the type of the immediate ancestor of a class. |
Constructor __construct (line 1274)
Overrides : Object::__construct() Constructs an object and initializes its data before the object is first used.
Method arc (line 1412)
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).
Method beginDraw (line 1368)
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.
Method bevelLine (line 1677)
Method bevelRect (line 1664)
Method clear (line 1688)
Use this method to erase all the drawings in the canvas
Method ellipse (line 1432)
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.
Method endDraw (line 1383)
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.
Method fillRect (line 1450)
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.
Method forceBrush (line 1292)
This method is used to set the color for the canvas to the brush color if the brush has been modified.
Method forceFont (line 1325)
This method is used to set the font for the canvas to the font property
Method forcePen (line 1308)
This method is used to set the stroke color for the canvas to the pen color if the pen has been modified.
Method frameRect (line 1469)
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.
Method initLibrary (line 1335)
Method line (line 1486)
Use Line to draw a 1 pixel wide line from a point (x1,y2) to another point (x2,y2) using the current Pen
Method paint (line 1699)
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.
Method polygon (line 1502)
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.
Method polyline (line 1533)
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.
Method rectangle (line 1569)
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.
Method roundRect (line 1593)
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.
Method stretchDraw (line 1642)
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.
Method textOut (line 1656)
Use TextOut to write a string onto the canvas. The string will be written using the current value of Font.