1e41f4b71Sopenharmony_ci# Path
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci路径绘制组件,根据绘制路径生成封闭的自定义形状。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## 子组件
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## 接口
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ciPath(value?: { width?: number | string; height?: number | string; commands?: string })
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**参数:**
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| 参数名                                             | 类型         | 必填 | 说明                   |
27e41f4b71Sopenharmony_ci| ------ | ---------------- | ---- | ------------------------------------------------------------ |
28e41f4b71Sopenharmony_ci| value  | { width?: number \| string; height?: number \| string; [commands](ts-drawing-components-path.md#commands)?: string } | 否   | width:路径所在矩形的宽度。<br/>值为异常值或缺省时按照自身内容需要的宽度处理。<br/>height:路径所在矩形的高度。<br/>值为异常值或缺省时按照自身内容需要的高度处理。<br/> commands:径绘制的命令字符串。默认值:''<br/>异常值按照默认值处理。|
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci## 属性
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci### commands
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_cicommands(value: string)
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci设置路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](ts-pixel-units.md)。
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**参数:** 
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                          |
49e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------- |
50e41f4b71Sopenharmony_ci| value  | string | 是   | 线条绘制的路径。<br/>默认值:'' |
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci### fill
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_cifill(value: ResourceColor)
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci设置填充区域颜色。异常值按照默认值处理。
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci**参数:** 
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci| 参数名 | 类型                                       | 必填 | 说明                                   |
67e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | -------------------------------------- |
68e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | 是   | 填充区域颜色。<br/>默认值:Color.Black |
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci### fillOpacity
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_cifillOpacity(value: number | string | Resource)
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci设置填充区域透明度。取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0,其余异常值按1.0处理。
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**参数:** 
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| 参数名 | 类型                                                         | 必填 | 说明                           |
85e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------ |
86e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 是   | 填充区域透明度。<br/>默认值:1 |
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci### stroke
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_cistroke(value: ResourceColor)
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci设置边框颜色,不设置时,默认没有边框线条。异常值不会绘制边框线条。
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**参数:** 
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci| 参数名 | 类型                                       | 必填 | 说明       |
103e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------- |
104e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | 是   | 边框颜色。 |
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci### strokeDashArray
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_cistrokeDashArray(value: Array&lt;any&gt;)
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci设置线条间隙。线段相交时可能会出现重叠现象。异常值按照默认值处理。
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**参数:** 
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| 参数名 | 类型             | 必填 | 说明                      |
121e41f4b71Sopenharmony_ci| ------ | ---------------- | ---- | ------------------------- |
122e41f4b71Sopenharmony_ci| value  | Array&lt;any&gt; | 是   | 线条间隙。<br/>默认值:[] |
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci### strokeDashOffset
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_cistrokeDashOffset(value: number | string)
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci设置线条绘制起点的偏移量。异常值按照默认值处理。
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci**参数:** 
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci| 参数名 | 类型                       | 必填 | 说明                                 |
139e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ------------------------------------ |
140e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string | 是   | 线条绘制起点的偏移量。<br/>默认值:0 |
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci### strokeLineCap
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_cistrokeLineCap(value: LineCapStyle)
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci设置线条端点绘制样式。
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**参数:** 
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci| 参数名 | 类型                                              | 必填 | 说明                                             |
157e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------- | ---- | ------------------------------------------------ |
158e41f4b71Sopenharmony_ci| value  | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 是   | 线条端点绘制样式。<br/>默认值:LineCapStyle.Butt |
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci### strokeLineJoin
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_cistrokeLineJoin(value: LineJoinStyle)
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci设置线条拐角绘制样式。
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**参数:** 
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci| 参数名 | 类型                                                | 必填 | 说明                                               |
175e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------- | ---- | -------------------------------------------------- |
176e41f4b71Sopenharmony_ci| value  | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 是   | 线条拐角绘制样式。<br/>默认值:LineJoinStyle.Miter |
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci### strokeMiterLimit
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_cistrokeMiterLimit(value: number | string)
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci设置斜接长度与边框宽度比值的极限值。斜接长度表示外边框外边交点到内边交点的距离,边框宽度即strokeWidth属性的值。该属性取值需在strokeLineJoin属性取值LineJoinStyle.Miter时生效。
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci该属性的合法值范围应当大于等于1.0,当取值范围在[0,1)时按1.0处理,其余异常值按默认值处理。
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**参数:** 
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci| 参数名 | 类型                       | 必填 | 说明                                           |
195e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ---------------------------------------------- |
196e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string | 是   | 斜接长度与边框宽度比值的极限值。<br/>默认值:4 |
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci### strokeOpacity
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_cistrokeOpacity(value: number | string | Resource)
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci设置线条透明度。该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0,其余异常值按1.0处理 。
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**参数:** 
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci| 参数名 | 类型                                                         | 必填 | 说明                       |
213e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | -------------------------- |
214e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 是   | 线条透明度。<br/>默认值:1 |
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci### strokeWidth
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_cistrokeWidth(value: Length)
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci设置线条宽度。该属性若为string类型, 暂不支持百分比,百分比按照1px处理。
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**参数:** 
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci| 参数名 | 类型                         | 必填 | 说明                     |
231e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------ |
232e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | 是   | 线条宽度。<br/>默认值:1 |
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci### antiAlias
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ciantiAlias(value: boolean)
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci设置是否开启抗锯齿效果。
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**参数:** 
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci| 参数名 | 类型    | 必填 | 说明                                  |
249e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------- |
250e41f4b71Sopenharmony_ci| value  | boolean | 是   | 是否开启抗锯齿效果。<br/>默认值:true |
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci## Commands
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_cicommands支持的绘制命令如下:
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci| 命令   | 名称                               | 参数                                       | 说明                                       |
257e41f4b71Sopenharmony_ci| ---- | -------------------------------- | ---------------------------------------- | ---------------------------------------- |
258e41f4b71Sopenharmony_ci| M    | moveto                           | (x y)                                    | 在给定的 (x, y) 坐标处开始一个新的子路径。例如,`M 0 0` 表示将(0, 0)点作为新子路径的起始点。 |
259e41f4b71Sopenharmony_ci| L    | lineto                           | (x y)                                    | 从当前点到给定的 (x, y) 坐标画一条线,该坐标成为新的当前点。例如,`L 50 50` 表示绘制当前点到(50, 50)点的直线,并将(50, 50)点作为新子路径的起始点。 |
260e41f4b71Sopenharmony_ci| H    | horizontal lineto                | x                                        | 从当前点绘制一条水平线,等效于将y坐标指定为0的L命令。例如,`H 50 ` 表示绘制当前点到(50, 0)点的直线,并将(50, 0)点作为新子路径的起始点。 |
261e41f4b71Sopenharmony_ci| V    | vertical lineto                  | y                                        | 从当前点绘制一条垂直线,等效于将x坐标指定为0的L命令。例如,`V 50 ` 表示绘制当前点到(0, 50)点的直线,并将(0, 50)点作为新子路径的起始点。 |
262e41f4b71Sopenharmony_ci| C    | curveto                          | (x1 y1 x2 y2 x y)                        | 使用 (x1, y1) 作为曲线起点的控制点, (x2, y2) 作为曲线终点的控制点,从当前点到 (x, y) 绘制三次贝塞尔曲线。例如,`C100 100 250 100 250 200 ` 表示绘制当前点到(250, 200)点的三次贝塞尔曲线,并将(250, 200)点作为新子路径的起始点。 |
263e41f4b71Sopenharmony_ci| S    | smooth curveto                   | (x2 y2 x y)                              | (x2, y2) 作为曲线终点的控制点,绘制从当前点到 (x, y) 绘制三次贝塞尔曲线。若前一个命令是C或S,则起点控制点是上一个命令的终点控制点相对于起点的映射。 例如,`C100 100 250 100 250 200 S400 300 400 200`第二段贝塞尔曲线的起点控制点为(250, 300)。如果没有前一个命令或者前一个命令不是 C或S,则第一个控制点与当前点重合。 |
264e41f4b71Sopenharmony_ci| Q    | quadratic Belzier curve          | (x1 y1 x y)                              | 使用 (x1, y1) 作为控制点,从当前点到 (x, y) 绘制二次贝塞尔曲线。例如,`Q400 50 600 300 ` 表示绘制当前点到(600, 300)点的二次贝塞尔曲线,并将(600, 300)点作为新子路径的起始点。 |
265e41f4b71Sopenharmony_ci| T    | smooth quadratic Belzier curveto | (x y)                                    | 绘制从当前点到 (x, y) 绘制二次贝塞尔曲线。若前一个命令是Q或T,则控制点是上一个命令的终点控制点相对于起点的映射。 例如,`Q400 50 600 300 T1000 300`第二段贝塞尔曲线的控制点为(800, 350)。 如果没有前一个命令或者前一个命令不是 Q或T,则第一个控制点与当前点重合。 |
266e41f4b71Sopenharmony_ci| A    | elliptical Arc                   | (rx ry x-axis-rotation large-arc-flag sweep-flag x y) | 从当前点到 (x, y) 绘制一条椭圆弧。椭圆的大小和方向由两个半径 (rx, ry) 和x-axis-rotation定义,指示整个椭圆相对于当前坐标系如何旋转(以度为单位)。 large-arc-flag 和 sweep-flag确定弧的绘制方式。 |
267e41f4b71Sopenharmony_ci| Z    | closepath                        | none                                     | 通过将当前路径连接回当前子路径的初始点来关闭当前子路径。             |
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci例如: commands('M0 20 L50 50 L50 100 Z')定义了一个三角形,起始于位置(0,20),接着绘制点(0,20)到点(50,50)的直线,再绘制点(50,50)到点(50,100)的直线,最后绘制点(50,100)到(0,20)的直线关闭路径,形成封闭三角形。
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci## 示例
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci```ts
274e41f4b71Sopenharmony_ci// xxx.ets
275e41f4b71Sopenharmony_ci@Entry
276e41f4b71Sopenharmony_ci@Component
277e41f4b71Sopenharmony_cistruct PathExample {
278e41f4b71Sopenharmony_ci  build() {
279e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
280e41f4b71Sopenharmony_ci      Text('Straight line')
281e41f4b71Sopenharmony_ci        .fontSize(11)
282e41f4b71Sopenharmony_ci        .fontColor(0xCCCCCC)
283e41f4b71Sopenharmony_ci        .width('90%')
284e41f4b71Sopenharmony_ci      // 绘制一条长600px,宽3vp的直线
285e41f4b71Sopenharmony_ci      Path()
286e41f4b71Sopenharmony_ci        .width('600px')
287e41f4b71Sopenharmony_ci        .height('10px')
288e41f4b71Sopenharmony_ci        .commands('M0 0 L600 0')
289e41f4b71Sopenharmony_ci        .stroke(Color.Black)
290e41f4b71Sopenharmony_ci        .strokeWidth(3)
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci      Text('Straight line graph')
293e41f4b71Sopenharmony_ci        .fontSize(11)
294e41f4b71Sopenharmony_ci        .fontColor(0xCCCCCC)
295e41f4b71Sopenharmony_ci        .width('90%')
296e41f4b71Sopenharmony_ci      // 绘制直线图形
297e41f4b71Sopenharmony_ci      Flex({ justifyContent: FlexAlign.SpaceBetween }) {
298e41f4b71Sopenharmony_ci        Path()
299e41f4b71Sopenharmony_ci          .width('210px')
300e41f4b71Sopenharmony_ci          .height('310px')
301e41f4b71Sopenharmony_ci          .commands('M100 0 L200 240 L0 240 Z')
302e41f4b71Sopenharmony_ci          .fillOpacity(0)
303e41f4b71Sopenharmony_ci          .stroke(Color.Black)
304e41f4b71Sopenharmony_ci          .strokeWidth(3)
305e41f4b71Sopenharmony_ci        Path()
306e41f4b71Sopenharmony_ci          .width('210px')
307e41f4b71Sopenharmony_ci          .height('310px')
308e41f4b71Sopenharmony_ci          .commands('M0 0 H200 V200 H0 Z')
309e41f4b71Sopenharmony_ci          .fillOpacity(0)
310e41f4b71Sopenharmony_ci          .stroke(Color.Black)
311e41f4b71Sopenharmony_ci          .strokeWidth(3)
312e41f4b71Sopenharmony_ci        Path()
313e41f4b71Sopenharmony_ci          .width('210px')
314e41f4b71Sopenharmony_ci          .height('310px')
315e41f4b71Sopenharmony_ci          .commands('M100 0 L0 100 L50 200 L150 200 L200 100 Z')
316e41f4b71Sopenharmony_ci          .fillOpacity(0)
317e41f4b71Sopenharmony_ci          .stroke(Color.Black)
318e41f4b71Sopenharmony_ci          .strokeWidth(3)
319e41f4b71Sopenharmony_ci      }.width('95%')
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci      Text('Curve graphics').fontSize(11).fontColor(0xCCCCCC).width('90%')
322e41f4b71Sopenharmony_ci      // 绘制弧线图形
323e41f4b71Sopenharmony_ci      Flex({ justifyContent: FlexAlign.SpaceBetween }) {
324e41f4b71Sopenharmony_ci        Path()
325e41f4b71Sopenharmony_ci          .width('250px')
326e41f4b71Sopenharmony_ci          .height('310px')
327e41f4b71Sopenharmony_ci          .commands("M0 300 S100 0 240 300 Z")
328e41f4b71Sopenharmony_ci          .fillOpacity(0)
329e41f4b71Sopenharmony_ci          .stroke(Color.Black)
330e41f4b71Sopenharmony_ci          .strokeWidth(3)
331e41f4b71Sopenharmony_ci        Path()
332e41f4b71Sopenharmony_ci          .width('210px')
333e41f4b71Sopenharmony_ci          .height('310px')
334e41f4b71Sopenharmony_ci          .commands('M0 150 C0 100 140 0 200 150 L100 300 Z')
335e41f4b71Sopenharmony_ci          .fillOpacity(0)
336e41f4b71Sopenharmony_ci          .stroke(Color.Black)
337e41f4b71Sopenharmony_ci          .strokeWidth(3)
338e41f4b71Sopenharmony_ci        Path()
339e41f4b71Sopenharmony_ci          .width('210px')
340e41f4b71Sopenharmony_ci          .height('310px')
341e41f4b71Sopenharmony_ci          .commands('M0 100 A30 20 20 0 0 200 100 Z')
342e41f4b71Sopenharmony_ci          .fillOpacity(0)
343e41f4b71Sopenharmony_ci          .stroke(Color.Black)
344e41f4b71Sopenharmony_ci          .strokeWidth(3)
345e41f4b71Sopenharmony_ci      }.width('95%')
346e41f4b71Sopenharmony_ci    }.width('100%')
347e41f4b71Sopenharmony_ci    .margin({ top: 5 })
348e41f4b71Sopenharmony_ci  }
349e41f4b71Sopenharmony_ci}
350e41f4b71Sopenharmony_ci```
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci![zh-cn_image_0000001219744193](figures/zh-cn_image_0000001219744193.png)