Graphic.Circle Class
This class extends the Shape class.
When you create a Circle object like var myCircle = new TW.Graphic.Circle();
the default radius of the object is 50pixels.
Note: the [x, y]
coordinates corresponds to the top left corner of the square which includes the circle.
If you want to draw to circle from its origin, you should consider moving its centerPoint:
circle.setAttr({
centerPoint: {
x: radius,
y: radius
}
});
Constructor
Graphic.Circle
-
[params]
Parameters:
-
[params]
Object optionalset of properties given to Circle.
params
is given to Shape constructor.-
[radius=50]
Number optionalradius of the circle.
-
Item Index
Methods
draw
-
context
This overridden draw method allow the Circle class to draw a circle on the context given in parameter.
Parameters:
-
context
CanvasRenderingContext2D
notifyParentChange
()
protected
This method notify the parent that a change has been done, and that it should clear his cache.
rotate
-
angle
This method allow you to rotate the Graphical object around the center point of the GraphicalObject.
Parameters:
-
angle
Numberrepresent the angle of rotation, it's expressed in degree.
scale
-
x
-
y
this method allow you to do a scale on the GraphicObject.
Parameters:
-
x
Numberthis is the x scale factor
-
y
Numberthis is the y scale factor
setAttr
-
attrs
Setter availlable for updating attibuts and correctly clear the caches. You can set all attributes supported by this instance (see the GraphicObject constructor for common available properties)
Parameters:
-
attrs
ObjectGraphicObject attributs. See the constructor for more details.
Example:
object.setAttr({
width: 20,
height: 20
});
object.setAttr({
pos: {
x: 0,
y: 0
}
});
skew
-
a
-
b
This method allow you to do a skew transform on the GraphicObject.
Parameters:
-
a
Numberthe factor of skew on the y axis
-
b
Numberthe factor of skew on the x axis
translate
-
x
-
y
This method allow you to translate the GraphicalObject, Internally this method modify the GraphicObject's matrix.
Parameters:
-
x
Numberthis is the translation scalar of the x axis.
-
y
Numberthis is the translation scalar of the y axis.
Properties
alpha
Number
value of opacity, between 0.0 (fully transparent) and 1.0 (opaque)
centerPoint
Object
default center of all matrix transformations.
values are exprimed depending on the size of the object. 0;0 is the up-left corner.
Sub-properties:
-
x
Object -
y
Object
color
fill color to draw this object.
Note: should be modified with setAttr
height
Number
matrix
Matrix
matrix applied to this object before draw.
mode
"WIRED" | "FILLED"
the draw mode of the current shape. Two modes are available "WIRED" and "FILLED".
Note: should be modified with setAttr
parent
Layer
parent containing this object.
radius
Number
Note: this property should be modified only with setAttr
strokeColor
color to apply to the stroke mode
Note: should be modified with setAttr
width
Number
x
Number
position on X axis
y
Number
position on Y axis
zIndex
Number
zIndex, used to determine the drawing order. Hight zIndex are drawn first.