add

add graphics

virtuosity.engine2d.graphics.add

Methods


Methods

container

Adds a container. A container holds graphics entities. This increases performance because when a property of an asset inside the container is changed, only that container needs to be redrawn. It is also faster to redraw the entities in batches as opposed to having each graphics entity seperate.

virtuosity.engine2d.graphics.add.container(id, canvas);


Parameter Type Description
id String unique id of the container
canvas String id of the canvas the container should be a part of

circle

adds a circle

virtuosity.engine2d.graphics.add.circle(id, container, x, y, radius, color);


Parameter Type Description
id String id of the circle
container String id of the container
x Number x position of the circle
y Number y position of the circle
radius Number radius of the circle
color Hex color of the circle

rectangle

adds a rectangle

virtuosity.engine2d.graphics.add.rectangle(id, container, x, y, width, height, color);


Parameter Type Description
id String id of the rectangle
container String id of the container
x Number x position of the rectangle
y Number y position of the rectangle
width Number width of the rectangle
height Number height of the rectangle
color Hex color of the rectangle

box

adds a box

virtuosity.engine2d.graphics.add.box(id, container, x, y, width, height, color, borderRadius);


Parameter Type Description
id String id of the box
container String id of the container
x Number x position of the box
y Number y position of the box
width Number width of the box
height Number height of the box
color Hex color of the box
borderRadius Int radius of the corners of the box

line

adds a line

virtuosity.engine2d.graphics.add.line(id, container, x1, y1, x2, y2, color);


Parameter Type Description
id String id of the line
container String id of the container
x1 Number x1 position of the line
y1 Number y1 position of the line
x2 Number x2 position of the line
y2 Number y2 position of the line
color Hex color of the line

ellipse

adds a ellipse

virtuosity.engine2d.graphics.add.ellipse(id, container, x, y, width, height, color);


Parameter Type Description
id String id of the ellipse
container String id of the container
x Number x position of the ellipse
y Number y position of the ellipse
width Number width of the ellipse
height Number height of the ellipse
color Hex color of the ellipse

torus

adds a torus

virtuosity.engine2d.graphics.add.torus(id, container, x, y, width, height, color);


Parameter Type Description
id String id of the torus
container String id of the container
x Number x position of the torus
y Number y position of the torus
width Number width of the torus
height Number height of the torus
color Hex color of the torus

polygon

adds a polygon

virtuosity.engine2d.graphics.add.polygon(id, container, points, color);


Parameter Type Description
id String id of the polygon
container String id of the container
points [Point] points of the polygon
color Hex color of the polygon