1e41f4b71Sopenharmony_ci# @ohos.arkui.shape (形状) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci在 clipShape 和 maskShape 接口中可以传入对应的形状。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci> **说明:** 7e41f4b71Sopenharmony_ci> 8e41f4b71Sopenharmony_ci> 从API version 12开始支持。后续版本的新增形状,采用上角标单独标记形状的起始版本。 9e41f4b71Sopenharmony_ci> 10e41f4b71Sopenharmony_ci> 示例效果请以真机运行为准,当前IDE预览器不支持。 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## 导入模块 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci```ts 15e41f4b71Sopenharmony_ciimport { CircleShape, EllipseShape, PathShape, RectShape } from "@kit.ArkUI"; 16e41f4b71Sopenharmony_ci``` 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci## CircleShape 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci用于 clipShape 和 maskShape 接口的圆形形状。 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci### constructor 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ciconstructor(options?: ShapeSize) 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 37e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 38e41f4b71Sopenharmony_ci| options | [ShapeSize](#shapesize) | 否 | 形状的大小。 | 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci继承自[BaseShape](#baseshape)。 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci## EllipseShape 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci用于 clipShape 和 maskShape 接口的椭圆形状。 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci### constructor 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ciconstructor(options?: ShapeSize) 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 61e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 62e41f4b71Sopenharmony_ci| options | [ShapeSize](#shapesize) | 否 | 形状的大小。 | 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci继承自[BaseShape](#baseshape)。 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci## PathShape 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci用于 clipShape 和 maskShape 接口的路径。 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci### constructor 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ciconstructor(options?: PathShapeOptions) 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 85e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 86e41f4b71Sopenharmony_ci| options | [PathShapeOptions](#pathshapeoptions) | 否 | 路径参数。 | 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci继承自[CommonShapeMethod](#commonshapemethod)。 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci### commands 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_cicommands(commands: string): PathShape 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci设置路径的绘制指令。 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 103e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 104e41f4b71Sopenharmony_ci| commands | string | 是 | 路径的绘制指令。 | 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci## RectShape 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci用于 clipShape 和 maskShape 接口的矩形形状。 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci### constructor 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ciconstructor(options?: RectShapeOptions | RoundRectShapeOptions) 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 125e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 126e41f4b71Sopenharmony_ci| options | [RectShapeOptions](#rectshapeoptions) \| [RoundRectShapeOptions](#roundrectshapeoptions) | 否 | 矩形形状参数。 | 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci继承自[BaseShape](#baseshape)。 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci### radiusWidth 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ciradiusWidth(rWidth: number | string): RectShape 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci设置矩形形状圆角半径的宽度。 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 143e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 144e41f4b71Sopenharmony_ci| rWidth | number \| string | 是 | 矩形形状圆角半径的宽度。 | 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci### radiusHeight 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ciradiusHeight(rHeight: number | string): RectShape 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci设置矩形形状圆角半径的高度。 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 159e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 160e41f4b71Sopenharmony_ci| rHeight | number \| string | 是 | 矩形形状圆角半径的高度。 | 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci### radius 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ciradius(radius: number | string | Array<number \| string>): RectShape 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci设置矩形形状的圆角半径。 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 175e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 176e41f4b71Sopenharmony_ci| radius | number \| string \| Array<number \| string> | 是 | 矩形形状的圆角半径。仅接受数组的前四个元素,分别为矩形左上,右上,左下,右下的圆角半径。 | 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci## ShapeSize 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci形状的尺寸参数。 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 190e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | -------------------------------------------- | -------------------------------------------- | 191e41f4b71Sopenharmony_ci| width | number \| string | 否 | 形状的宽度。 | 192e41f4b71Sopenharmony_ci| height | number \| string | 否 | 形状的高度。 | 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci## PathShapeOptions 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ciPathShape 的构造函数参数。 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 205e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | -------------------------------------------- | -------------------------------------------- | 206e41f4b71Sopenharmony_ci| commands | string | 否 | 绘制路径的指令。更多说明请参考commands支持的[绘制命令](./arkui-ts/ts-drawing-components-path.md#commands-1)。 | 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci## RectShapeOptions 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ciRectShape 的构造函数参数。 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci继承自[ShapeSize](#shapesize)。 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 221e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | -------------------------------------------- | -------------------------------------------- | 222e41f4b71Sopenharmony_ci| radius | number \| string \| Array<number \| string> | 否 | 矩形形状的圆角半径。 | 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci## RoundRectShapeOptions 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ciRectShape 带有半径的构造函数参数。 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci继承自[ShapeSize](#shapesize)。 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 237e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | -------------------------------------------- | -------------------------------------------- | 238e41f4b71Sopenharmony_ci| radiusWidth | number \| string | 否 | 矩形形状圆角半径的宽度。 | 239e41f4b71Sopenharmony_ci| radiusHeight | number \| string | 否 | 矩形形状圆角半径的高度。 | 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci## BaseShape 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_ci继承自[CommonShapeMethod](#commonshapemethod)。 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci### width 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ciwidth(width: Length): T 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci设置形状的宽度。 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 262e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 263e41f4b71Sopenharmony_ci| width | [Length](arkui-ts/ts-types.md#length) | 是 | 形状的宽度。 | 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci### height 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ciheight(height: Length): T 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci设置形状的高度。 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 278e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 279e41f4b71Sopenharmony_ci| height | [Length](arkui-ts/ts-types.md#length) | 是 | 形状的高度。 | 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci### size 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_cisize(size: SizeOptions): T 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci设置形状的大小。 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 294e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 295e41f4b71Sopenharmony_ci| size | [SizeOptions](arkui-ts/ts-types.md#sizeoptions) | 是 | 形状的大小。 | 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci## CommonShapeMethod 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci### offset 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_cioffset(offset: Position): T 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci设置相对于组件布局位置的坐标偏移。 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 316e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 317e41f4b71Sopenharmony_ci| offset | [Position](arkui-ts/ts-types.md#position) | 是 | 相对于组件布局位置的坐标偏移。 | 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci### fill 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_cifill(color: ResourceColor): T 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ci设置形状的填充区域的透明度,黑色表示完全透明,白色表示完全不透明。 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 332e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 333e41f4b71Sopenharmony_ci| color | [ResourceColor](arkui-ts/ts-types.md#resourcecolor) | 是 | 形状的填充区域的透明度,黑色表示完全透明,白色表示完全不透明。 | 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci### position 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ciposition(position: Position): T 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci设置形状的位置。 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 | 348e41f4b71Sopenharmony_ci| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | 349e41f4b71Sopenharmony_ci| position | [Position](arkui-ts/ts-types.md#position) | 是 | 设置形状的位置。 | 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci## **示例** 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci```ts 354e41f4b71Sopenharmony_ciimport { CircleShape, EllipseShape, PathShape, RectShape } from "@kit.ArkUI"; 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci@Entry 357e41f4b71Sopenharmony_ci@Component 358e41f4b71Sopenharmony_cistruct ShapeExample { 359e41f4b71Sopenharmony_ci build() { 360e41f4b71Sopenharmony_ci Column({ space: 15 }) { 361e41f4b71Sopenharmony_ci Text('CircleShape, position').fontSize(20).width('75%').fontColor('#DCDCDC') 362e41f4b71Sopenharmony_ci Image($r('app.media.startIcon')) 363e41f4b71Sopenharmony_ci .clipShape(new CircleShape({ width: '280px', height: '280px' }).position({ x: '20px', y: '20px' })) 364e41f4b71Sopenharmony_ci .width('500px').height('280px') 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci Text('EllipseShape, offset').fontSize(20).width('75%').fontColor('#DCDCDC') 367e41f4b71Sopenharmony_ci Image($r('app.media.startIcon')) 368e41f4b71Sopenharmony_ci .clipShape(new EllipseShape({ width: '350px', height: '280px' }).offset({ x: '10px', y: '10px' })) 369e41f4b71Sopenharmony_ci .width('500px').height('280px') 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci Text('PathShape, fill').fontSize(20).width('75%').fontColor('#DCDCDC') 372e41f4b71Sopenharmony_ci Image($r('app.media.startIcon')) 373e41f4b71Sopenharmony_ci .maskShape(new PathShape().commands('M100 0 L200 240 L0 240 Z').fill(Color.Red)) 374e41f4b71Sopenharmony_ci .width('500px').height('280px') 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci Text('RectShape, width, height, fill').fontSize(20).width('75%').fontColor('#DCDCDC') 377e41f4b71Sopenharmony_ci Image($r('app.media.startIcon')) 378e41f4b71Sopenharmony_ci .maskShape(new RectShape().width('350px').height('280px').fill(Color.Red)) 379e41f4b71Sopenharmony_ci .width('500px').height('280px') 380e41f4b71Sopenharmony_ci } 381e41f4b71Sopenharmony_ci .width('100%') 382e41f4b71Sopenharmony_ci .margin({ top: 15 }) 383e41f4b71Sopenharmony_ci } 384e41f4b71Sopenharmony_ci} 385e41f4b71Sopenharmony_ci``` 386