November 2011
Intermediate to advanced
348 pages
7h 2m
English
In addition to translations and rotations, the HTML5 canvas API also provides us with a means for scaling the canvas context. In this recipe, we'll scale down the height of the canvas context using the scale() method.

Follow these steps to draw a scaled rectangle:
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var rectWidth = 150;
var rectHeight = 75;// translate context to center of canvas context.translate(canvas.width ...
Read now
Unlock full access