Name
drawview — Adds procedural drawing APIs to view.
Details
Properties (7)
-
cachebitmap
-
<attribute name="cachebitmap" value="true" />
If true, the bitmap result will be cached where possible.
-
context
-
<attribute name="context" value="null" />
Contains a reference to the raw drawview context. oncontext is sent when the context is ready to use, which can take some
time in IE.
-
fillStyle
-
<attribute name="fillStyle" type="string" value="#000000" />
public var fillStyle : String;
Represents the colour or style to use for the fill inside the shapes. Can be either a hexadecimal number (0xffffff), a CSS
string ('#ff00ff' or '#f0f'), or a CanvasGradient/LzCanvasGradient.
-
globalAlpha
-
<attribute name="globalAlpha" type="number" value="1" />
public var globalAlpha : Number;
Gives an alpha value that is applied to shapes and images
before they are composited onto the canvas. The valid range of
values is from 0.0 (fully transparent) to 1.0 (no additional
transparency). If the attribute is set to values outside this range,
they are ignored. When the context is created, the globalAlpha
attribute initially has the value 1.0.
-
lineCap
-
<attribute name="lineCap" type="string" value="round" />
public var lineCap : string;
Gives the default lineCap value for lines. Round for consistency between swf and dhtml.
-
lineWidth
-
<attribute name="lineWidth" type="number" value="1" />
public var lineWidth : Number;
Gives the default width of lines, in coordinate space units.
Negative values are ignored. 0 draws hairlines in swf - lines that
are always 1 pixel wide even when scaled.
-
strokeStyle
-
<attribute name="strokeStyle" type="string" value="#000000" />
public var strokeStyle : String;
Represents the colour to use for the lines around shapes. Specified as a hexadecimal number (0xffffff) or a CSS string ('#ff00ff'
or '#f0f').
Methods (14)
-
arc()
-
<method name="arc" args="x, y, radius, startAngle, endAngle, clockwise" />
public function arc(x : Number, y : Number, radius : Number, startAngle : Number, endAngle : Number, clockwise : Number);
Adds an arc to the current path. The arc is a segment of a circle that has radius as given.
The circle segment is determined by the two angles startAngle and endAngle and begins at the given coordinate (x,y).
If clockwise is true, the arc is drawn clockwise from startAngle to endAngle, otherwise it is drawn counter-clockwise
(anti-clockwise).
-
beginPath()
-
<method name="beginPath" />
public function beginPath();
Resets the list of subpaths to an empty list, and calls moveTo() with the point (0,0).
-
bezierCurveTo()
-
<method name="bezierCurveTo" args="cp1x, cp1y, cp2x, cp2y, x, y" />
public function bezierCurveTo(cp1x : Number, cp1y : Number, cp2x : Number, cp2y : Number, x : Number, y : Number);
bezierCurveTo() adds the given coordinate (x, y) to the list of points of
the subpath, and connects the two points with a bezier curve with control
points (cp1x, cp1y) and (cp2x, cp2y). It then sets the current position to
the given coordinate (x, y).
-
clear()
-
-
closePath()
-
<method name="closePath" />
public function closePath();
Adds a straight line from the current position to the first point in the last subpath and marks the subpath as closed, if
the last subpath isn't closed, and if it has more than one point in its list of points. If the last subpath is not open or
has only one point, it does nothing.
-
createLinearGradient()
-
<method name="createLinearGradient" args="x0, y0, x1, y1" />
public function createLinearGradient(x0 : Number, y0 : Number, x1 : Number, y1 : Number) : LzCanvasGradient;
Takes four arguments, representing the start point (x0, y0) and end point (x1, y1) of the gradient, in coordinate space units,
and returns an object representing a linear gradient initialised with that line.
Linear gradients are rendered such that at the starting point on the canvas the colour at offset 0 is used, that at
the ending point the color at offset 1 is used, that all points on a line perpendicular to the line between the start and
end points have the colour at the point where those two lines cross. (Of course, the colours are only painted where the shape
they are being painted on needs them.)
-
createRadialGradient()
-
<method name="createRadialGradient" args="x0, y0, r0, x1, y1, r1" />
public function createRadialGradient(x0 : Number, y0 : Number, r0 : Number, x1 : Number, y1 : Number, r1 : Number) : LzCanvasGradient;
Takes six arguments, the first three representing the start point (x0, y0) and rotation r0, and the last three representing
the end point (x1, y1) and radius r1. The values are in coordinate space units.
Rotation doesn't appear to work for radial gradients. Even so, it can be set by specifying r0 in radians. r1 is ignored.
-
fill()
-
Fills each subpath of the current path in turn, using fillStyle, and using the non-zero winding number rule. Open subpaths
are implicitly closed when being filled (without affecting the actual subpaths).
Note that closePath() is called before the line is filled.
-
lineTo()
-
<method name="lineTo" args="x, y" />
public function lineTo(x : Number, y : Number);
Adds the given coordinate (x, y) to the list of points of the subpath, and connects the current position to that point with
a straight line. It then sets the current position to the given coordinate (x, y).
-
moveTo()
-
<method name="moveTo" args="x, y" />
public function moveTo(x, y);
Sets the current position to the given coordinate and creates a new subpath with that point as its first (and only) point.
If there was a previous subpath, and it consists of just one point, then that subpath is removed from the path.
-
oval()
-
<method name="oval" args="x, y, radius, yRadius" />
public function oval(x, y, radius, yRadius);
-
quadraticCurveTo()
-
<method name="quadraticCurveTo" args="cpx, cpy, x, y" />
public function quadraticCurveTo(cpx : Number, cpy : Number, x : Number, y : Number);
Adds the given coordinate (x, y) to the list of points of the subpath, and connects the current position to that point with
a quadratic curve with control point (cpx, cpy). It then sets the current position to the given coordinate (x, y).
-
rect()
-
<method name="rect" args="x, y, w, h, cornerRadius" />
public function rect(x : Number, y : Number, w : Number, h : Number, cornerRadius : Number);
Rect creates a new subpath containing just the rectangle with top left coordinate (x, y), width w and height h.
based on mc.drawRect() - by Ric Ewing (ric@formequalsfunction.com)
-
stroke()
-
public function stroke();
Strokes each subpath of the current path in turn, using the strokeStyle and lineWidth attributes.
Events (1)
-
oncontext
-
<attribute name="oncontext" />
Sent when the context is ready to use, which can take some time in IE.
LZX Synopsis
<class name="
lz.drawview" extends="
LzView
">
<attribute name="
context
" value="
null" />
<attribute name="
fillStyle
" type="
string" value="
#000000" />
<attribute name="
globalAlpha
" type="
number" value="
1" />
<attribute name="
lineCap
" type="
string" value="
round" />
<attribute name="
lineWidth
" type="
number" value="
1" />
<attribute name="
strokeStyle
" type="
string" value="
#000000" />
<method name="
arc
" args="
x,
y,
radius,
startAngle,
endAngle,
clockwise" />
<method name="
bezierCurveTo
" args="
cp1x,
cp1y,
cp2x,
cp2y,
x,
y" />
<method name="
clear
" />
<method name="
lineTo
" args="
x,
y" />
<method name="
moveTo
" args="
x,
y" />
<method name="
oval
" args="
x,
y,
radius,
yRadius" />
<method name="
rect
" args="
x,
y,
w,
h,
cornerRadius" />
</class>
JavaScript Synopsis
public
lz.drawview extends
LzView
{
prototype public function
arc
(
x : Number,
y : Number,
radius : Number,
startAngle : Number,
endAngle : Number,
clockwise : Number);
prototype public function
bezierCurveTo
(
cp1x : Number,
cp1y : Number,
cp2x : Number,
cp2y : Number,
x : Number,
y : Number);
prototype public function
clear
();
prototype public function
createLinearGradient
(
x0 : Number,
y0 : Number,
x1 : Number,
y1 : Number) :
LzCanvasGradient;
prototype public function
createRadialGradient
(
x0 : Number,
y0 : Number,
r0 : Number,
x1 : Number,
y1 : Number,
r1 : Number) :
LzCanvasGradient;
prototype public function
fill
();
prototype public function
lineTo
(
x : Number,
y : Number);
prototype public function
moveTo
(
x,
y);
prototype public function
oval
(
x,
y,
radius,
yRadius);
prototype public function
quadraticCurveTo
(
cpx : Number,
cpy : Number,
x : Number,
y : Number);
prototype public function
rect
(
x : Number,
y : Number,
w : Number,
h : Number,
cornerRadius : Number);
prototype public function
stroke
();
}