SVG <path>
- Previous Page SVG Line Chart
- Next Page SVG Filter Introduction
<path> tag is used to define a path.
<path> tag
<path> tag is used to define a path.
The following commands can be used for path data:
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Belzier curve
- T = smooth quadratic Belzier curveto
- A = elliptical Arc
- Z = closepath
Note:All the above commands allow lowercase letters. Uppercase indicates absolute positioning, lowercase indicates relative positioning.
Please copy the following code to a text editor, then save the file as "path1.svg". Place this file in your web directory:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="M250 150 L150 350 L350 350 Z" /> </svg>
The above example defines a path that starts at position 250 150, reaches position 150 350, then starts from there to 350 350, and finally closes the path at 250 150.
The following example creates a spiral:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="M153 334 C153 334 151 334 151 334 C151 339 153 344 156 344 C164 344 171 339 171 334 C171 322 164 314 156 314 C142 314 131 322 131 334 C131 350 142 364 156 364 C175 364 191 350 191 334 C191 311 175 294 156 294 C131 294 111 311 111 334 C111 361 131 384 156 384 C186 384 211 361 211 334 C211 300 186 274 156 274" style="fill:white;stroke:red;stroke-width:2"/> </svg>
Very complex? Yes!!! Due to the complexity of drawing paths, it is strongly recommended that you use an SVG editor to create complex graphics.
- Previous Page SVG Line Chart
- Next Page SVG Filter Introduction