1# Circle 2 3圆形绘制组件。 4 5> **说明:** 6> 7> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 8 9 10## 权限列表 11 12无 13 14 15## 子组件 16 17无 18 19 20## 接口 21 22Circle(options?: {width?: string | number, height?: string | number}) 23 24**参数:** 25 26| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | 27| -------- | -------- | -------- | -------- | -------- | 28| width | string \| number | 否 | 0 | 宽度。 | 29| height | string \| number | 否 | 0 | 高度。 | 30 31 32## 属性 33 34除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: 35 36| 名称 | 类型 | 默认值 | 描述 | 37| -------- | -------- | -------- | -------- | 38| fill | [ResourceColor](ts-types.md#resourcecolor8) | Color.Black | 设置填充区域颜色。 | 39| fillOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | 设置填充区域透明度。 | 40| stroke | [ResourceColor](ts-types.md#resourcecolor8) | - | 设置边框颜色,不设置时,默认没有边框。 | 41| strokeDashArray | Array<Length> | [] | 设置边框间隙。 | 42| strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。 | 43| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。 | 44| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | 45| strokeMiterLimit | number \| string | 4 | 设置斜接长度与边框宽度比值的极限值。<br/>**说明:**<br/>Circle组件无法设置尖角图形,该属性设置无效。 | 46| strokeOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | 设置边框透明度。<br/>**说明:**<br/>该属性的取值范围是[0.0, 1.0],若给定值小于0.0,则取值为0.0;若给定值大于1.0,则取值为1.0。 | 47| strokeWidth | Length | 1 | 设置边框宽度。 | 48| antiAlias | boolean | true | 是否开启抗锯齿效果。 | 49 50 51## 示例 52 53```ts 54// xxx.ets 55@Entry 56@Component 57struct CircleExample { 58 build() { 59 Column({ space: 10 }) { 60 // 绘制一个直径为150的圆 61 Circle({ width: 150, height: 150 }) 62 // 绘制一个直径为150、线条为红色虚线的圆环(宽高设置不一致时以短边为直径) 63 Circle() 64 .width(150) 65 .height(200) 66 .fillOpacity(0) 67 .strokeWidth(3) 68 .stroke(Color.Red) 69 .strokeDashArray([1, 2]) 70 }.width('100%') 71 } 72} 73``` 74 75 76