I am using the HTML canvas tag to draw around 3000, vector lines on a small area (900x500) the target platform is mobile which has inherently lower spec'd hardware. On my desktop I can make the 3000 vector lines render, using moveto and lineto in about 25ms. However on the mobile device it's more like 700ms which is significantly slower. What is the most effective way to render these lines which make up a complex shape using canvas? Would the canvas pixel API be better suited to this task? My current code looks something like this:
var myArray = []; //contains 3000 objects with X & Y & type
for(var i = 0; i<myArray.length; i++) {
if(myArray.type = "moveTo") {
canvasElement.moveTo(myArray[i].X, myArray[i].Y);
} else {
canvasElement.lineTo(myArray[i].X, myArray[i].Y);
}
}
canvasElement.stroke();
Thanks