November 2011
Intermediate to advanced
348 pages
7h 2m
English
One of the most common applications of the scale transform is to stretch a circle horizontally or vertically to create an oval. In this recipe, we'll create an oval by translating the canvas context, stretching it horizontally, and then drawing a circle.

Follow these steps to draw an oval:
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");context.save(); // save state
var centerX = 0; var ...
Read now
Unlock full access