ts-drawing-components-polyline.md 1.9 KB
Newer Older
Z
zengyawen 已提交
1
# Polyline
Z
zengyawen 已提交
2

Z
zengyawen 已提交
3

E
esterzhou 已提交
4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
Z
zengyawen 已提交
5
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
6

Z
zengyawen 已提交
7 8 9 10 11

The **<Polyline>** component is used to draw a polyline.


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

None

Z
zengyawen 已提交
15 16

## Child Components
Z
zengyawen 已提交
17 18 19 20

None


Z
zengyawen 已提交
21 22 23 24 25
## APIs

Polyline(options?: {width: Length, height: Length})

- Parameters
E
esterzhou 已提交
26
    | Name | Type | Mandatory | Default Value | Description | 
Z
zengyawen 已提交
27
  | -------- | -------- | -------- | -------- | -------- |
E
esterzhou 已提交
28
  | options | Object | No | - | For details, see the **options** parameters. | 
Z
zengyawen 已提交
29 30

- options parameters
E
esterzhou 已提交
31
    | Name | Type | Mandatory | Default Value | Description | 
Z
zengyawen 已提交
32 33 34 35 36 37 38
  | -------- | -------- | -------- | -------- | -------- |
  | width | Length | Yes | - | Width. | 
  | height | Length | Yes | - | Height. | 


## Attributes

E
esterzhou 已提交
39
  | Name | Type | Default Value | Mandatory | Description | 
Z
zengyawen 已提交
40
| -------- | -------- | -------- | -------- | -------- |
E
esterzhou 已提交
41 42 43
| width | Length | 0 | No | Width of the rectangle where the polyline is located. | 
| height | Length | 0 | No | Height of the rectangle where the polyline is located. | 
| points | Array<Point> | - | Yes | List of coordinates that the polyline passes through. | 
Z
zengyawen 已提交
44 45 46 47 48


## Example

  
Z
zengyawen 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
```
@Entry
@Component
struct PolylineExample {
  build() {
    Column({ space: 5 }) {
      Flex({ justifyContent: FlexAlign.SpaceAround }) {
        // Draw a polyline in a 100 x 100 rectangle. The start point is (0, 0), the end point is (100, 100), and the passing point is (20,60).
        Polyline({ width: 100, height: 100 }).points([[0, 0], [20, 60], [100, 100]])
        // Draw a polyline in a 100 x 100 rectangle. The start point is (0, 0), the end point is (100, 100), and the passing point is (0,100).
        Polyline().width(100).height(100).points([[0, 0], [0, 100], [100, 100]])
      }.width('100%')
    }.margin({ top: 5 })
  }
}
```

Z
zengyawen 已提交
66
![en-us_image_0000001212218432](figures/en-us_image_0000001212218432.gif)