Colored shapes renderer. Responsible to drawing a batch of basic geometric shapes with as little draw calls as possible.
Kind: global class
function
Boolean
Number
Number
Boolean
Create the sprites batch.
Param | Type | Description |
---|---|---|
[batchPolygonsCount] | Number |
Internal buffers size, in polygons count (polygon = 3 vertices). Bigger value = faster rendering but more RAM. |
function
Optional method to trigger when shapes batch overflows and can’t contain any more polygons.
Kind: instance property of ShapesBatch
Boolean
If true, will floor vertices positions before pushing them to batch.
Kind: instance property of ShapesBatch
Kind: instance property of ShapesBatch
Kind: instance property of ShapesBatch
Number
Get how many polygons are currently in batch.
Kind: instance property of ShapesBatch
Returns: Number
- Polygons in batch count.
Number
Get how many polygons this sprite batch can contain.
Kind: instance property of ShapesBatch
Returns: Number
- Max polygons count.
Boolean
Check if this batch is full.
Kind: instance property of ShapesBatch
Returns: Boolean
- True if batch is full.
Kind: instance method of ShapesBatch
Kind: instance method of ShapesBatch
Draw a line between two points. This method actually uses a rectangle internally, which is less efficient than using a proper LinesBatch, but have the advantage of supporting width.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
fromPoint | Vector2 |
Starting position. |
toPoint | Vector2 |
Ending position. |
color | Color |
Line color. |
[width] | Number |
Line width. |
Push vertices to drawing batch.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
vertices | Array.<Vertex> |
Vertices to push. Vertices count must be dividable by 3 to keep the batch consistent of polygons. |
Add a rectangle to draw.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
position | Vector2 | Vector3 |
Drawing position (at origin). If vector3 is provided, will pass z value to the shader code position attribute. |
size | Vector2 | Vector3 | Number |
Drawing size. If vector3 is provided, will pass z value to the shader code position attribute for the bottom vertices, as position.z + size.z. |
color | Color | Array.<Color> | undefined |
Rectangle color, or undefined to not change color. If array is set, will assign each color to different vertex, starting from top-left. |
[rotation] | Number |
Rotate rectangle. |
[origin] | Vector2 |
Drawing origin. This will be the point at ‘position’ and rotation origin. |
[skew] | Vector2 |
Skew the drawing corners on X and Y axis, around the origin point. |
Adds a 1x1 point.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
position | Vector2 | Vector3 |
Point position. |
color | Color |
Point color. |
Add a rectangle that covers a given destination rectangle.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
destRect | Rectangle | Vector2 |
Destination rectangle to draw on. If vector is provided, will draw from 0,0 with vector as size. |
color | Color | Array.<Color> | undefined |
Rectangle color, or undefined to not change color. If array is set, will assign each color to different vertex, starting from top-left. |
[rotation] | Number |
Rotate rectangle. |
[origin] | Vector2 |
Drawing origin. This will be the point at ‘position’ and rotation origin. |
Draw a colored circle.
Kind: instance method of ShapesBatch
Param | Type | Description |
---|---|---|
circle | Circle |
Circle to draw. |
color | Color |
Circle fill color. |
[segmentsCount] | Number |
How many segments to build the circle from (more segments = smoother circle). |
[outsideColor] | Color |
If provided, will create a gradient-colored circle and this value will be the outter side color. |
ratio | Number | Vector2 |
If procided, will scale the circle on X and Y axis to turn it into an oval. If a number is provided, will use this number to scale Y axis. |
[rotation] | Number |
If provided will rotate the oval / circle. |