• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Ellipse
2
3The **\<Ellipse>** component is used to draw an ellipse.
4
5>  **NOTE**
6>
7>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## Child Components
11
12Not supported
13
14
15## APIs
16
17Ellipse(options?: {width?: string | number, height?: string | number})
18
19Since API version 9, this API is supported in ArkTS widgets.
20
21**Parameters**
22
23| Name| Type| Mandatory| Description|
24| -------- | -------- | -------- | -------- |
25| width | string \| number | No| Width.<br>Default value: **0**|
26| height | string \| number | No| Height.<br>Default value: **0**|
27
28## Attributes
29
30In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
31
32| Name| Type| Default Value| Description|
33| -------- | -------- | -------- | -------- |
34| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.<br>Since API version 9, this API is supported in ArkTS widgets.|
35| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.<br>Since API version 9, this API is supported in ArkTS widgets.|
36| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
37| strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes.<br>Since API version 9, this API is supported in ArkTS widgets.|
38| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
39| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
40| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not work for the **\<ellipse>** component, which does not have corners.|
41| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not take effect for the **\<Ellipse>** component, because it does not have a miter join.|
42| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.|
43| strokeWidth | Length | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value cannot be a percentage.|
44| antiAlias | boolean | true | Whether anti-aliasing is enabled.<br>Since API version 9, this API is supported in ArkTS widgets.|
45
46
47## Example
48
49```ts
50// xxx.ets
51@Entry
52@Component
53struct EllipseExample {
54  build() {
55    Column({ space: 10 }) {
56      // Draw a 150 x 80 ellipse.
57      Ellipse({ width: 150, height: 80 })
58      // Draw a 150 x 100 ellipse with blue strokes.
59      Ellipse()
60        .width(150)
61        .height(100)
62        .fillOpacity(0)
63        .stroke(Color.Blue)
64        .strokeWidth(3)
65    }.width('100%')
66  }
67}
68```
69
70![en-us_image_0000001174104394](figures/en-us_image_0000001174104394.png)
71