new Shape()
Shape Component is responsible for rendering a shape to the screen. Basic Shapes such as circles, rectangles, etc. can be rendered using this component.
Shape.CIRCLE = 0;
Shape.RECTANGLE = 1;
Shape.LINE = 2;
Shape.TRIANGLE = 3;
Shape.POLYGON = 4;
| Name | Type | Default | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
geometry | number | Shape.CIRCLE | The Geometry of the shape. | ||||||||||||||||||||||||
color | Color | Color.fuchsia | The color of the shape. | ||||||||||||||||||||||||
fill | boolean | true | Whether the shape is filled or not. | ||||||||||||||||||||||||
param | Object | More Optional parameters for the shape. Properties
|
- Source
// Create a shape component
let shape = new Shape(Shape.CIRCLE,Color.fuchsia,true,{radius:10});
// Add the shape component to an entity
entity.addComponent(shape);Extends
Members
blendMode
Blend mode of the object
- Inherited From
- Source
color :Color
Color of the shape.
- Source
fill :boolean
Fill the shape or not.
- boolean
- Source
filter
The filter applied to the object
- Inherited From
- Source
geometry :number
Geometry of the shape. Can be one of the following:
Shape.CIRCLE = 0;
Shape.RECTANGLE = 1;
Shape.LINE = 2;
Shape.TRIANGLE = 3;
Shape.POLYGON = 4;
- number
- Source
height
If the shape is Rectangle. The height of the rectangle.
- Source
outline :Color
Outline of the shape.
- Source
(readonly) properties
The entity that this component is attached to.
- Inherited From
- Source
radius :number
If shape is Circle. The radius of the circle.
- number
- Source
thickness :number
The thickness of the outline of the shape.
- number
- Source
width :number
If the shape is Rectangle. The width of the rectangle.
- number
- Source
Methods
deserialize(props)
Populates the component properties from a data object. Override this method for custom property handling.
| Name | Type | Description |
|---|---|---|
props | object | The properties object (usually from JSON). |
- Overrides
- Source
drawChildren()
Draw this entity's nested renderables in deterministic order. @protected
- Inherited From
- Source