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