O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

DRAW PATHS ON THE CANVAS

Complex and irregular shapes can be drawn as canvas paths, generated by placing an “invisible ink” pen at a specific location and defining straight lines, arcs, or curves to build a shape. That shape can be filled or stroked, which draws it to screen.

All paths must begin with beginPath(). This removes all points established by any earlier paths. Note that previously drawn paths will remain on the canvas; this function just removes any of the analogous invisible ink.

Path-generation methods allow you to control your invisible ink pen:

  • moveTo(x, y) — This moves the pen to a specific location in the canvas. This is useful as the first method in a new path to define where you want the path to begin.
  • lineTo(x, y) — This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required