Original: http://tutorials.jenkov.com/svg/polygon-element.html Polyline
Although I did not use this element, but it is quite powerful, also translated under
Example
<svg xmlns= "Http://www.w3.org/2000/svg" xmlns:xlink= "Http://www.w3.org/1999/xlink" > <polyline points= "0,0 30,0 15,30" style= "Stroke: #006600;" /></svg>
The effect is as follows
Polylines are defined by defining many points, where each point in the points attribute is a form of x, Y, and this example has 3 points
The polyline is filled by linking these three points, and the default fill color is black
Look at the additional fill effect
<svg xmlns= "Http://www.w3.org/2000/svg" xmlns:xlink= "Http://www.w3.org/1999/xlink" > <polyline points= "10,2 60,2 35,52" style= "Stroke: #006600; stroke-width:2; Fill: #33cc33; " /></svg>
Effect
By contrast, how do we find that the border is missing an edge?
Because only two points will be linked! To draw a closed triangle
The code is as follows
<svg xmlns= "Http://www.w3.org/2000/svg" xmlns:xlink= "Http://www.w3.org/1999/xlink" > <polyline points= "10,2 60,2 35,52 10,2" style= "Stroke: #006600; fill: #33cc33;" /></svg>
Set the last point to be the same as the starting point, and you can see the closed triangles.
Polygon
First look at a polygon example
<svg xmlns= "Http://www.w3.org/2000/svg" xmlns:xlink= "Http://www.w3.org/1999/xlink" > <polygon points= "10,0 60,0 35,50" style= "Stroke: #660000; fill: #cc3333;" /></svg>
The effect is as follows
By observing the code and the effects found, there are only 3 points inside the points, but the inside 3 sides are drawn.
Because the polygon element connects all points together, including the first point and the last point.
The polyline element is not connected to the last point and the first point.
It's like the biggest difference between polygon and polyline.
A more dramatic 8 variant.
<svg xmlns= "Http://www.w3.org/2000/svg" xmlns:xlink= "Http://www.w3.org/1999/xlink" > <polygon points= "50,5 100,5 125,30 125,80 100,105 50,105 25,80 ," style= "Stroke: #660000; Fill: #cc3333; Stroke-width:3; " /></svg>
[SVG translation Tutorial] Polyline (polyline) polygon (polygon)