Game Development Reference
In-Depth Information
ctx.fillStyle = "#fff";
ctx.fillRect(0, 0, canvas.width, canvas.height);
// With transformations, order is very important
ctx.scale(2, 1);
ctx.translate(50, 50);
ctx.rotate(0.80);
ctx.translate(10, -20);
ctx.fillStyle = "#f00";
ctx.fillRect(0, 0, 50, 50);
With transformations, order is very important.
Drawing images
Probably the most exciting and useful feature of the 2D canvas API from a game de-
velopment perspective, is its ability to draw images onto it. Thankfully, for us, there
Search WWH ::




Custom Search