XML technologies / SVG / Using complex graphic elements and formatting / Using paths correctly / Closing paths automatically

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

In previous examples creating a complete closed object, such as the crown in Drawing more complex objects, the path was closed manually: the last command ended at the path’s starting point.

There is a very simple way to close a path automatically: end it with z. The following example creates a triangle with only two lines by closing the path after the last line with z.

<path d="M200 200 L300 150 L50 50 z" style="stroke-miterlimit:4;stroke-linejoin:miter;stroke-linecap:round;stroke-width:1;stroke-opacity:1;stroke:rgb(0,0,0);fill-opacity:1;fill:none;opacity:1"/>

The browser displays this result:

An automatically closed path

Figure: An automatically closed path.

   

 

 

 

back to top