Draws a shape onto the Canvas.

 

   
Syntax
 
     

[Visual Basic]
Function Canvas.DrawShape(inShape As String, inParams As String) As System.Drawing.Rectangle

[C#]
System.Drawing.Rectangle Canvas.DrawShape(string inShape, string inParams);

 

   
Params
 
     
Name   Description
inShape A string indicating the shape to be drawn (see below).
inParams A parameter string containing Override parameters, Positioning parameters, Transform parameters and Shape Manipulation parameters.
return

The Rect (before transformation) of the area drawn to.

 

   
Notes
 
     

Allows you to draw a shape onto the Canvas. The following shapes are available.

  • "rectangle" or "rect"
  • "line"
  • "polygon" or "poly" (this is a closed object)
  • "roundrectangle" or "roundrect"
  • "oval"

Rectangles, round rectangles and ovals are drawn to fill the rectangle supplied in the Parameter String.

Lines and polygons require a Points parameter to be supplied to specify where the corners of the shape are.

Lines which are filled become polygons (i.e. the end points are joined).

 

   
See Also
 
     

Canvas DrawData function.

 

   
Example
 
     

[Visual Basic]
Dim ca As New Canvas
Dim inpath, outpath As String
inpath = Server.MapPath("rez/layers.psd")
outpath = Server.MapPath("drawshape.jpg")
ca.PaintColor = System.Drawing.Color.Blue
ca.PenSize = 4
ca.Width = 250
ca.Height = 250
ca.DrawShape("oval", "Pos=10,10 Size=100,100 Operation=both")
ca.DrawShape("line", "Points=120,120,200,170,130,200 Operation=draw OpenGL=true")
ca.DrawShape("roundrect", "Pos=20,120 Size=80,80 Operation=draw OpenGL=true")
ca.DrawShape("poly", "Points=120,20,200,40,120,100 Operation=draw")
ca.DrawShape("oval", "Pos=0,0 Size=250,250 Operation=draw OpenGL=true")
ca.DrawShape("rect", "Pos=0,0 Size=250,250 Operation=draw")
ca.SaveAs(outpath, "Quality=high")

[C#]
Canvas ca = new Canvas();
string inpath = Server.MapPath("rez/layers.psd");
string outpath = Server.MapPath("drawshape.jpg");
ca.PaintColor = System.Drawing.Color.Blue;
ca.PenSize = 4;
ca.Width = 250;
ca.Height = 250;
ca.DrawShape("oval", "Pos=10,10 Size=100,100 Operation=both");
ca.DrawShape("line", "Points=120,120,200,170,130,200 Operation=draw OpenGL=true");
ca.DrawShape("roundrect", "Pos=20,120 Size=80,80 Operation=draw OpenGL=true");
ca.DrawShape("poly", "Points=120,20,200,40,120,100 Operation=draw");
ca.DrawShape("oval", "Pos=0,0 Size=250,250 Operation=draw OpenGL=true");
ca.DrawShape("rect", "Pos=0,0 Size=250,250 Operation=draw");
ca.SaveAs(outpath, "Quality=high");

The code draws a number of shapes using a number of different options. Note that the top two shapes are drawn without OpenGL and the bottom two with it.

drawshapes.jpg