[SVG translation Tutorial] Polyline (polyline) polygon (polygon)

Source: Internet
Author: User
Tags polyline

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.