Skip to Main Content
Painting the Web
book

Painting the Web

by Shelley Powers
May 2008
Beginner content levelBeginner
656 pages
17h 41m
English
O'Reilly Media, Inc.
Content preview from Painting the Web

Paths, Patterns, and Markers

A line is nice but limited, in that you can only use it to draw from here to there. Polylines and polygons can be used to create more complex images, but not images where the drawing "pen" is moved to a new location in the page without drawing any figure between. The SVG path removes these limitations by providing the ability to draw any number of connected or non-connected points, creating complex lines or even complete images once they're filled in and colored.

Unlike the polygon and polyline functionality discussed in the previous section, a path doesn't take a sequence of points and connect them. Instead, a path takes a sequence of commands and draws the image, or images, based on these commands. The commands are case sensitive, and the type of "lines" drawn change from straight line to curved. Complex drawings generated by drawing tools, like those described later, are invariably created as paths.

Basic Path Commands

Path commands either move the drawing "pen," draw straight lines, or draw curves. They're case sensitive, in that lowercase commands are relative and uppercase are absolute. The basic commands are:

M or m

The moveto command (relative or absolute) moves the digital pen to a new location, beginning a new subpath.

L or l

The lineto command (relative or absolute) draws a line from the current location to the new.

Z or z

Closes the current subpath by drawing a straight line from the current location to the initial starting point.

The path is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 9780596515096Supplemental ContentErrata Page