The Graphics class exposes an easy to use API for generating vector drawing instructions and drawing them to a specified context.
Note that you can use Graphics without any dependency on the Easel framework by calling draw() directly,
or it can be used with the Shape object to draw vector graphics within the context of an Easel display list.
var g = new Graphics();
g.setStrokeStyle(1);
g.beginStroke(Graphics.getRGB(0,0,0));
g.beginFill(Graphics.getRGB(255,0,0));
g.drawCircle(0,0,3);
var s = new Shape(g);
s.x = 100;
s.y = 100;
stage.addChild(s);
stage.update();
Note that all drawing methods in Graphics return the Graphics instance, so they can be chained together. For example, the following
line of code would generate the instructions to draw a rectangle with a red stroke and blue fill, then render it to the specified
context2D:
myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(myContext2D);