What is the difference between Polygon and Polyline in SVG? I replaced all the dots in those 2 samples and the results were exactly the same (in Google Chrome):
Is it just semantic difference without any actual result?
A line is simply a separate line or segment that is not joined to another line. While a Polyline indicates two or more lines have been joined.
If there are more polygons, each relationship will result in one line. For instance, if two polygons are on the left of a third polygon and share a boundary with it, "polygon to line (with neighbour)" creates two lines.
A Polyline object is a shape defined by one or more paths, in which a path is a series of connected segments.
A polyline is a list of points, where line segments are drawn between consecutive points. A polyline has the following properties: Points. The vertices of the line. Line segments are drawn between consecutive points.
Try to add this:
style="fill:yellow;stroke:purple;stroke-width:1"
to both examples , instead of
fill="red"
and you'll see difference.
Polyline doesn't connect last point to first ! Polygon - always connects last point to the first. Problem was, that line color and fill color were the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With