js-components-svg-polygon.md 1.5 KB
Newer Older
E
ester.zhou 已提交
1
# polygon
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3
The **\<polygon>** component is used to draw a polygon.
Z
zengyawen 已提交
4 5


E
ester.zhou 已提交
6 7 8 9 10
>  **NOTE**
>
>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.

## Required Permissions
Z
zengyawen 已提交
11 12 13 14

None


E
ester.zhou 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
## Child Components

The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).


## Attributes

The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.

| Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | string | - | No| Unique ID of the component.|
| points | string | - | No| Multiple coordinates of the polygon.<br>The format is [x1,y1 x2,y2 x3,y3].<br>Attribute animations are supported. If the number of coordinates of the animation change value set in the attribute animation is different from the format of the original points, the attribute animation is invalid.|


## Example

```html
Z
zengyawen 已提交
33 34 35 36 37 38 39 40 41 42
<!-- xxx.hml -->
<div class="container">
  <svg fill="white" stroke="blue" width="400" height="400">
    <polygon points="10,110 60,35 60,85 110,10" fill="red"></polygon>
    <polygon points="10,200 60,125 60,175 110,100" stroke-dasharray="10 5" stroke-dashoffset="3"></polygon>
  </svg>
</div>
```


E
ester.zhou 已提交
43
![en-us_image_0000001173324721](figures/en-us_image_0000001173324721.png)