function draw() {
cx.beginPath(); cx.lineWidth = 4;
cx.fillStyle = "yellow"; cx.strokeStyle = "blue";
cx.arc(50, 50, 40, 0, 2*Math.PI);
cx.fill(); cx.stroke();
cx.fillStyle = "black";
cx.fillText("arc",44,55);
cx.beginPath(); cx.lineWidth = 5;
cx.fillStyle = "pink"; cx.strokeStyle = "red";
cx.rect(110, 10, 100, 80);
cx.fill(); cx.stroke();
cx.fillStyle = "black";
cx.fillText("rect",148,55);
}
Ref: Eloquent JavaScript, Chap 17