A class which allows you to draw custom graphics on a UserView or Window.
The following methods must be called within a Window: -drawFunc or a UserView: -drawFunc function, and will only be visible once the window or the view is refreshed. Each call to Window: -refresh or UserView: -refresh will 'overwrite' all previous drawing by executing the currently defined function, unless UserView: -clearOnRefresh is set to false
The following methods define paths. You will need to call *stroke or *fill to actually draw them.
Draw a line (define a path) from the current position to point.
point |
An instance of Point |
Draw a line (define a path) from p1 to p2. Current position will be p2.
p1 |
An instance of Point |
p2 |
An instance of Point |
Draws a cubic bezier curve from the current position to point. cpoint1 and cpoint2 are control points determining the curve's curvature.
endPoint |
An instance of Point |
cPoint1 |
An instance of Point |
cPoint2 |
An instance of Point |
Draws a quad bezier curve from the current position to point. cpoint is a control point determining the curve's curvature.
endPoint |
An instance of Point |
cPoint |
An instance of Point |
Draws an arc of a circle using a radius and tangent points.
point1 |
The end point of the first tangent line. Its start point is the current position. An instance of Point |
point2 |
The end point of the second tangent line. Its start point is point1. An instance of Point |
radius |
The radius of the arc. |
example:
Draw an arc around the Point center, at radius number of pixels. startAngle and arcAngle refer to the starting angle and the extent of the arc, and are in radians [0..2pi].
example:
Draw a wedge around the Point center, at radius number of pixels. startAngle and sweepLength refer to the starting angle and the extent of the arc, and are in radians [0..2pi].
example:
Draw an annular wedge around the Point center, from innerRadius to outerRadius in pixels. startAngle and sweepLength refer to the starting angle and the extent of the arc, and are in radians [0..2pi].
example:
Adds an Oval shape that fits inside the Rect to the current path.
Outline the previous defined path.
example:
Fill the previous defined path.
example:
Draw the previous defined path using any of the following options:
style |
|
example:
Fill and stroke the current path. Shortcut to the draw(3) method.
These methods do not require separate calls to *stroke or *fill.
Strokes a Rect into the window.
Draws a filled Rect into the window.
Strokes an oval into the window.
Draws a filled oval into the window.
Fills an Axial gradient.
example:
Fills a Radial gradient.
example:
The following commands transform the graphics state, i.e. they effect all subsequent drawing commands. These transformations are cumulative, i.e. each command applies to the previous graphics state, not the original one.
Translate the coordinate system to have its origin moved by x,y
example:
Cumulative translations:
Scales subsequent drawing. x and y are scaling factors (i.e. 1 is normal, 2 is double size, etc.).
example:
Skews subsequent drawing. x and y are skewing factors (i.e. 1 is normal).
example:
Rotates subsequent drawing around the Point x@y
by the amount angle in radians [0..2pi].
example:
Gets or sets the coordinate system transformation matrix.
See Matrix example for an example.
matrixArray |
An array of the form |
Sets the width of the Pen for the whole stroke
Draw function, and then revert to the previous graphics state. This allows you to make complex transformations of the graphics state without having to explicitly revert to get back to 'normal'.
example:
Make a path, consisting of the drawing made in function.
Discard any previous path.
Begins a new transparency layer. Transparency layers are useful when you want to apply an effect to a group of objects or create a composite graphic. See Transparency layer example.
Ends the current transparency layer.
Use the previously defined path as a clipping path.
example:
Turns on/off anti-aliasing.
example:
Will fill the current path with a shadow. You should use this option between Pen.push / Pen.pop (or Pen.use)
Set the lines joining style according to the defined options:
0 | miter |
1 | round |
2 | bevel |
Set the lines joining style according to the defined options:
0 | butt |
1 | round |
2 | square |
example:
Set the opacity level.
Set the blending mode to use. See Blending modes for more information.
Set the line dash pattern. pattern should be a FloatArray of values that specify the lengths of the painted segments and not painted segments.
Draw a bitmap image using the Image class.
example:
Simple rotating and scaling:
Redraw at random interval, different every time:
Uses random seed to 'store' data By reseting the seed each time the same random values and shapes are generated for each 'frame' These can then be subjected to cumulative rotation, etc., by simply incrementing the phase var.