This demo shows how to draw lines. Click anywhere on the canvas to add line segments.
The following shows a minimal code example on how to draw line segments.
// create lines batch
let linesBatch = new Shaku.gfx.LinesBatch();
linesBatch.linesStrip = true;
// lines to draw
let lines = [
new Shaku.gfx.Vertex(new Shaku.utils.Vector2(50,50), null, Shaku.utils.Color.random()),
new Shaku.gfx.Vertex(new Shaku.utils.Vector2(150,150), null, Shaku.utils.Color.random())
];
// part below goes between startFrame() and endFrame()
// -------------------------------------------------------
// draw the lines
// note: you can also use drawRectangle(), drawCircle() and other useful methods, but then you should set linesStrip=false or they'll connect
linesBatch.begin();
linesBatch.drawVertices(lines);
linesBatch.end();