Class shape2d
Extends
component.
shape2d
Defined in: shape2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
shape2d()
Component that can express basic 2D shapes and polygons.
|
Field Attributes | Field Name and Description |
---|---|
Whether the shape should be drawn using the absolute positions
of its geometry.
|
|
Color of the shape.
|
|
The rendering mode.
|
|
The transform of the shape component.
|
- Fields borrowed from class component:
- host, info, isDrawing, isStepping, onAttach, onDraw, onStep, tag
Method Attributes | Method Name and Description |
---|---|
formCircle(radius, numIterations)
Forms the shape into an estimated circle made of triangles.
|
|
formImage(image, forcedWidth, forcedHeight)
Forms the shape into a visual of an image.
|
|
formImageFrame(image, frame, forcedWidth, forcedHeight)
Forms the aspect into a frame of an image.
|
|
formLines(pts)
Forms a collection of line segments.
|
|
formRectangle(width, height)
Forms the shape into a rectangle.
|
|
formTriangles(pts)
Forms the shape into a collection of triangle primitives.
|
- Methods borrowed from class component:
- canHandleEvent, draw, emitEvent, getKnownEvents, installEvent, installHandler, installHook, step, uninstallEvent, uninstallHandler, uninstallHook
Field Detail
absolute
Whether the shape should be drawn using the absolute positions
of its geometry. If absolute, node information is ignored.
color
Color of the shape.
mode
The rendering mode. See sandboxe.render2d.renderMode
node
The transform of the shape component.
Method Detail
formCircle(radius, numIterations)
Forms the shape into an estimated circle made of triangles.
- Parameters:
- {Number} radius
- The radius of the circle. Measured in pixels.
- {Number} numIterations
- Number of sides that the circle should have. The more iterations, the smoother the circle will become, but the more resource-intensive the shape becomes as well.
formImage(image, forcedWidth, forcedHeight)
Forms the shape into a visual of an image.
If the image has multiple frames, the image is drawn as
an animation.
- Parameters:
- {asset} image
- The image to display as the aspect. If image does not refer to a valid Image, no action is taken. If the Image has multiple frames, the subsequent frame is drawn upon next draw() of the shape2d.
- {Number} forcedWidth
- Optional forced width
- {Number} forcedHeight
- Optional forced height
formImageFrame(image, frame, forcedWidth, forcedHeight)
Forms the aspect into a frame of an image.
Behaves like formImage(), but a specific frame index is
specified to draw rather than the image as an animation.
- Parameters:
- {asset} image
- The image to form as the aspect. If image does not refer to a valid image asset, no action is taken
- {Number} frame
- The frame of the image to use, starting at 0. If the frame is negative, the aspect is drawn as if formImage() had been called.
- {Number} forcedWidth
- Optional forced width
- {Number} forcedHeight
- Optional forced height
formLines(pts)
Forms a collection of line segments.
Every two points form a line segment. If an odd number of points are given, the last point is ignored.
- Parameters:
- {Array} pts
- The points of the lines as individual components, that is, pairs of X-Y values.
formRectangle(width, height)
Forms the shape into a rectangle.
The top-left corner of the rectangle is the origin.
Width and height are expressed in pixels.
- Parameters:
- {Number} width
- The width of the rectangle in pixels.
- {Number} height
- The height of the rectangle in pixels.
formTriangles(pts)
Forms the shape into a collection of triangle primitives.
The points are interpreted as pixels and are expected to be in groups of 3.
If a non-multiple-of-three number of points is given,
the remainder points are ignored.
- Parameters:
- {Array} pts
- The points of the triangles as individual components, that is, pairs of X-Y values.