1e41f4b71Sopenharmony_ci# Line
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **\<Line>** component is used to draw a straight line.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Child Components
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciNot supported
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## APIs
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ciLine(value?: {width?: string | number, height?: string | number})
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**Parameters**
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
23e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
24e41f4b71Sopenharmony_ci| width | string \| number | No| Width.<br>**NOTE**<br>If the value is invalid or the default value is used, the width required for the content is used.|
25e41f4b71Sopenharmony_ci| height | string \| number | No| Height.<br>**NOTE**<br>If the value is invalid or the default value is used, the height required for the content is used.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci## Attributes
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci### startPoint
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_cistartPoint(value: Array&lt;any&gt;)
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciSets the coordinates (relative coordinates) of the start point of the line. An invalid value is handled as the default value.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**Parameters**
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| Name| Type                                     | Mandatory| Description                                                        |
44e41f4b71Sopenharmony_ci| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
45e41f4b71Sopenharmony_ci| value  | Array&lt;[Length](ts-types.md#length)&gt; | Yes  | Coordinates (relative coordinates) of the start point of the line, in vp.<br>Default value: **[0, 0]**|
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci### endPoint
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciendPoint(value: Array&lt;any&gt;)
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciSets the coordinates (relative coordinates) of the end point of the line. An invalid value is handled as the default value.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**Parameters**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci| Name| Type                                     | Mandatory| Description                                                        |
60e41f4b71Sopenharmony_ci| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
61e41f4b71Sopenharmony_ci| value  | Array&lt;[Length](ts-types.md#length)&gt; | Yes  | Coordinates (relative coordinates) of the end point of the line, in vp.<br>Default value: **[0, 0]**|
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci### fill
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_cifill(value: ResourceColor)
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciSets the color of the fill area. This attribute does not take effect because the **\<Line>** component cannot be used to draw a closed shape.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**Parameters**
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                                  |
76e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | -------------------------------------- |
77e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Color of the fill area.<br>Default value: **Color.Black**|
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci### fillOpacity
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_cifillOpacity(value: number | string | Resource)
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ciSets the opacity of the fill area. This attribute does not take effect because the **\<Line>** component cannot be used to draw a closed shape.
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci**Parameters**
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                          |
92e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------ |
93e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Opacity of the fill area.<br>Default value: **1**|
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci### stroke
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_cistroke(value: ResourceColor)
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ciSets the stroke color. If this attribute is not set, the component does not have any stroke. If the value is invalid, no stroke will be drawn.
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci**Parameters**
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description      |
108e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------- |
109e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Stroke color.|
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci### strokeDashArray
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_cistrokeDashArray(value: Array&lt;any&gt;)
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ciSets stroke dashes. Line segments may overlap when they intersect. An invalid value is handled as the default value.
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci**Parameters**
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci| Name| Type                                     | Mandatory| Description                     |
124e41f4b71Sopenharmony_ci| ------ | ----------------------------------------- | ---- | ------------------------- |
125e41f4b71Sopenharmony_ci| value  | Array&lt;[Length](ts-types.md#length)&gt; | Yes  | Stroke dashes.<br>Default value: **[]**|
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci### strokeDashOffset
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_cistrokeDashOffset(value: number | string)
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ciSets the offset of the start point for drawing the stroke.
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci**Parameters**
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci| Name| Type                      | Mandatory| Description                                |
140e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ------------------------------------ |
141e41f4b71Sopenharmony_ci| value  | number \| string | Yes  | Offset of the start point for drawing the stroke.<br>Default value: **0**|
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci### strokeLineCap
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_cistrokeLineCap(value: LineCapStyle)
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ciSets the cap style of the stroke.
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci**Parameters**
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci| Name| Type                                             | Mandatory| Description                                            |
156e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------- | ---- | ------------------------------------------------ |
157e41f4b71Sopenharmony_ci| value  | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Yes  | Cap style of the stroke.<br>Default value: **LineCapStyle.Butt**|
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci### strokeLineJoin
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_cistrokeLineJoin(value: LineJoinStyle)
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ciSets the join style of the stroke. This attribute does not work for the **\<Line>** component, which does not have corners.
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**Parameters**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci| Name| Type                                               | Mandatory| Description                                              |
172e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------- | ---- | -------------------------------------------------- |
173e41f4b71Sopenharmony_ci| value  | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Yes  | Join style of the stroke.<br>Default value: **LineJoinStyle.Miter**|
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci### strokeMiterLimit
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_cistrokeMiterLimit(value: number | string)
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ciLimit value when the sharp angle is drawn as a miter. This attribute does not take effect because the **\<Line>** component cannot be used to draw a shape with a sharp angle.
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**Parameters**
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci| Name| Type                      | Mandatory| Description                                  |
188e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | -------------------------------------- |
189e41f4b71Sopenharmony_ci| value  | number \| string | Yes  | Limit value when the sharp angle is drawn as a miter.<br>Default value: **4**|
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci### strokeOpacity
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_cistrokeOpacity(value: number | string | Resource)
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ciSets the stroke opacity. The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci**Parameters**
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                      |
204e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | -------------------------- |
205e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Stroke opacity.<br>Default value: **1**|
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci### strokeWidth
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_cistrokeWidth(value: Length)
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ciSets the stroke width. If of the string type, this attribute cannot be set in percentage. A percentage is processed as 1px.
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Parameters**
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci| Name| Type                        | Mandatory| Description                    |
220e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------ |
221e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Stroke width.<br>Default value: **1**|
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci### antiAlias
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ciantiAlias(value: boolean)
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ciSpecifies whether anti-aliasing is enabled.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**Parameters**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                 |
236e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------- |
237e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether anti-aliasing is enabled.<br>Default value: **true**|
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci## Example
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci### Example 1
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci```ts
244e41f4b71Sopenharmony_ci// xxx.ets
245e41f4b71Sopenharmony_ci@Entry
246e41f4b71Sopenharmony_ci@Component
247e41f4b71Sopenharmony_cistruct LineExample {
248e41f4b71Sopenharmony_ci  build() {
249e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
250e41f4b71Sopenharmony_ci      // The coordinates of the start and end points of the line are determined relative to the coordinates of the drawing area of the <Line> component.
251e41f4b71Sopenharmony_ci      Line()
252e41f4b71Sopenharmony_ci        .width(200)
253e41f4b71Sopenharmony_ci        .height(150)
254e41f4b71Sopenharmony_ci        .startPoint([0, 0])
255e41f4b71Sopenharmony_ci        .endPoint([50, 100])
256e41f4b71Sopenharmony_ci        .stroke(Color.Black)
257e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
258e41f4b71Sopenharmony_ci      Line()
259e41f4b71Sopenharmony_ci        .width(200)
260e41f4b71Sopenharmony_ci        .height(150)
261e41f4b71Sopenharmony_ci        .startPoint([50, 50])
262e41f4b71Sopenharmony_ci        .endPoint([150, 150])
263e41f4b71Sopenharmony_ci        .strokeWidth(5)
264e41f4b71Sopenharmony_ci        .stroke(Color.Orange)
265e41f4b71Sopenharmony_ci        .strokeOpacity(0.5)
266e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
267e41f4b71Sopenharmony_ci      // strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered.
268e41f4b71Sopenharmony_ci      Line()
269e41f4b71Sopenharmony_ci        .width(200)
270e41f4b71Sopenharmony_ci        .height(150)
271e41f4b71Sopenharmony_ci        .startPoint([0, 0])
272e41f4b71Sopenharmony_ci        .endPoint([100, 100])
273e41f4b71Sopenharmony_ci        .stroke(Color.Black)
274e41f4b71Sopenharmony_ci        .strokeWidth(3)
275e41f4b71Sopenharmony_ci        .strokeDashArray([10, 3])
276e41f4b71Sopenharmony_ci        .strokeDashOffset(5)
277e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
278e41f4b71Sopenharmony_ci      // If the coordinates of a point are beyond the width and height range of the <Line> component, the line will exceed the drawing area.
279e41f4b71Sopenharmony_ci      Line()
280e41f4b71Sopenharmony_ci        .width(50)
281e41f4b71Sopenharmony_ci        .height(50)
282e41f4b71Sopenharmony_ci        .startPoint([0, 0])
283e41f4b71Sopenharmony_ci        .endPoint([100, 100])
284e41f4b71Sopenharmony_ci        .stroke(Color.Black)
285e41f4b71Sopenharmony_ci        .strokeWidth(3)
286e41f4b71Sopenharmony_ci        .strokeDashArray([10, 3])
287e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
288e41f4b71Sopenharmony_ci    }
289e41f4b71Sopenharmony_ci  }
290e41f4b71Sopenharmony_ci}
291e41f4b71Sopenharmony_ci```
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci![en-us_image_0000001219982725](figures/en-us_image_0000001219982725.png)
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci### Example 2
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci```ts
298e41f4b71Sopenharmony_ci// xxx.ets
299e41f4b71Sopenharmony_ci@Entry
300e41f4b71Sopenharmony_ci@Component
301e41f4b71Sopenharmony_cistruct LineExample1 {
302e41f4b71Sopenharmony_ci  build() {
303e41f4b71Sopenharmony_ci    Row({ space: 10 }) {
304e41f4b71Sopenharmony_ci      // Set LineCapStyle to Butt.
305e41f4b71Sopenharmony_ci      Line()
306e41f4b71Sopenharmony_ci        .width(100)
307e41f4b71Sopenharmony_ci        .height(200)
308e41f4b71Sopenharmony_ci        .startPoint([50, 50])
309e41f4b71Sopenharmony_ci        .endPoint([50, 200])
310e41f4b71Sopenharmony_ci        .stroke(Color.Black)
311e41f4b71Sopenharmony_ci        .strokeWidth(20)
312e41f4b71Sopenharmony_ci        .strokeLineCap(LineCapStyle.Butt)
313e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5').margin(10)
314e41f4b71Sopenharmony_ci      // Set LineCapStyle to Round.
315e41f4b71Sopenharmony_ci      Line()
316e41f4b71Sopenharmony_ci        .width(100)
317e41f4b71Sopenharmony_ci        .height(200)
318e41f4b71Sopenharmony_ci        .startPoint([50, 50])
319e41f4b71Sopenharmony_ci        .endPoint([50, 200])
320e41f4b71Sopenharmony_ci        .stroke(Color.Black)
321e41f4b71Sopenharmony_ci        .strokeWidth(20)
322e41f4b71Sopenharmony_ci        .strokeLineCap(LineCapStyle.Round)
323e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
324e41f4b71Sopenharmony_ci      // Set LineCapStyle to Square.
325e41f4b71Sopenharmony_ci      Line()
326e41f4b71Sopenharmony_ci        .width(100)
327e41f4b71Sopenharmony_ci        .height(200)
328e41f4b71Sopenharmony_ci        .startPoint([50, 50])
329e41f4b71Sopenharmony_ci        .endPoint([50, 200])
330e41f4b71Sopenharmony_ci        .stroke(Color.Black)
331e41f4b71Sopenharmony_ci        .strokeWidth(20)
332e41f4b71Sopenharmony_ci        .strokeLineCap(LineCapStyle.Square)
333e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
334e41f4b71Sopenharmony_ci    }
335e41f4b71Sopenharmony_ci  }
336e41f4b71Sopenharmony_ci}
337e41f4b71Sopenharmony_ci```
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci![en-us_image1_0000001219982725](figures/en-us_image1_0000001219982725.png)
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci### Example 3
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci```ts
344e41f4b71Sopenharmony_ci// xxx.ets
345e41f4b71Sopenharmony_ci@Entry
346e41f4b71Sopenharmony_ci@Component
347e41f4b71Sopenharmony_cistruct LineExample {
348e41f4b71Sopenharmony_ci  build() {
349e41f4b71Sopenharmony_ci    Column() {
350e41f4b71Sopenharmony_ci      Line()
351e41f4b71Sopenharmony_ci        .width(300)
352e41f4b71Sopenharmony_ci        .height(30)
353e41f4b71Sopenharmony_ci        .startPoint([50, 30])
354e41f4b71Sopenharmony_ci        .endPoint([300, 30])
355e41f4b71Sopenharmony_ci        .stroke(Color.Black)
356e41f4b71Sopenharmony_ci        .strokeWidth(10)
357e41f4b71Sopenharmony_ci      // Set the interval for strokeDashArray to 50.
358e41f4b71Sopenharmony_ci      Line()
359e41f4b71Sopenharmony_ci        .width(300)
360e41f4b71Sopenharmony_ci        .height(30)
361e41f4b71Sopenharmony_ci        .startPoint([50, 20])
362e41f4b71Sopenharmony_ci        .endPoint([300, 20])
363e41f4b71Sopenharmony_ci        .stroke(Color.Black)
364e41f4b71Sopenharmony_ci        .strokeWidth(10)
365e41f4b71Sopenharmony_ci        .strokeDashArray([50])
366e41f4b71Sopenharmony_ci      // Set the interval for strokeDashArray to 50, 10.
367e41f4b71Sopenharmony_ci      Line()
368e41f4b71Sopenharmony_ci        .width(300)
369e41f4b71Sopenharmony_ci        .height(30)
370e41f4b71Sopenharmony_ci        .startPoint([50, 20])
371e41f4b71Sopenharmony_ci        .endPoint([300, 20])
372e41f4b71Sopenharmony_ci        .stroke(Color.Black)
373e41f4b71Sopenharmony_ci        .strokeWidth(10)
374e41f4b71Sopenharmony_ci        .strokeDashArray([50, 10])
375e41f4b71Sopenharmony_ci      // Set the interval for strokeDashArray to 50, 10, 20.
376e41f4b71Sopenharmony_ci      Line()
377e41f4b71Sopenharmony_ci        .width(300)
378e41f4b71Sopenharmony_ci        .height(30)
379e41f4b71Sopenharmony_ci        .startPoint([50, 20])
380e41f4b71Sopenharmony_ci        .endPoint([300, 20])
381e41f4b71Sopenharmony_ci        .stroke(Color.Black)
382e41f4b71Sopenharmony_ci        .strokeWidth(10)
383e41f4b71Sopenharmony_ci        .strokeDashArray([50, 10, 20])
384e41f4b71Sopenharmony_ci      // Set the interval for strokeDashArray to 50, 10, 20, 30.
385e41f4b71Sopenharmony_ci      Line()
386e41f4b71Sopenharmony_ci        .width(300)
387e41f4b71Sopenharmony_ci        .height(30)
388e41f4b71Sopenharmony_ci        .startPoint([50, 20])
389e41f4b71Sopenharmony_ci        .endPoint([300, 20])
390e41f4b71Sopenharmony_ci        .stroke(Color.Black)
391e41f4b71Sopenharmony_ci        .strokeWidth(10)
392e41f4b71Sopenharmony_ci        .strokeDashArray([50, 10, 20, 30])
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci    }
395e41f4b71Sopenharmony_ci  }
396e41f4b71Sopenharmony_ci}
397e41f4b71Sopenharmony_ci```
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci![en-us_image2_0000001219982725](figures/en-us_image2_0000001219982725.PNG)
400