November 2011
Intermediate to advanced
348 pages
7h 2m
English
In this recipe, we'll introduce path drawing by iteratively connecting line subpaths to draw a zigzag path.

Follow these steps to draw a zigzag path:
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var startX = 85;
var startY = 70;
var zigzagSpacing = 60;context.lineWidth = 10;
context.strokeStyle = "#0096FF"; // blue-ish color
context.beginPath();
context.moveTo(startX, startY);Read now
Unlock full access