1e41f4b71Sopenharmony_ci# Ellipse
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **\<Ellipse>** component is used to draw an ellipse.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Child Components
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNot supported
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## APIs
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciEllipse(options?: {width?: string | number, height?: string | number})
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Parameters**
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
24e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
25e41f4b71Sopenharmony_ci| width | string \| number | No| Width.<br>Default value: **0**<br>**NOTE**<br>An invalid value is handled as the default value.|
26e41f4b71Sopenharmony_ci| height | string \| number | No| Height.<br>Default value: **0**<br>**NOTE**<br>An invalid value is handled as the default value.|
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## Attributes
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci### fill
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_cifill(value: ResourceColor)
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciSets the color of the fill area. An invalid value is handled as the default value.
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**Parameters**
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                                  |
45e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | -------------------------------------- |
46e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Color of the fill area.<br>Default value: **Color.Black**|
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci### fillOpacity
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_cifillOpacity(value: number | string | Resource)
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciSets the opacity of the fill area. The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**Parameters**
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                          |
61e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------ |
62e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | Yes  | Opacity of the fill area.<br>Default value: **1**|
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci### stroke
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_cistroke(value: ResourceColor)
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ciSets the stroke color. If this attribute is not set, the component does not have any stroke. If the value is invalid, no stroke will be drawn.
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**Parameters**
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description      |
77e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------- |
78e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Stroke color.|
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci### strokeDashArray
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_cistrokeDashArray(value: Array&lt;any&gt;)
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ciSets stroke dashes. An invalid value is handled as the default value.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**Parameters**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| Name| Type            | Mandatory| Description                     |
93e41f4b71Sopenharmony_ci| ------ | ---------------- | ---- | ------------------------- |
94e41f4b71Sopenharmony_ci| value  | Array&lt;any&gt; | Yes  | Stroke dashes.<br>Default value: **[]**|
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci### strokeDashOffset
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_cistrokeDashOffset(value: number | string)
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ciSets the offset of the start point for drawing the stroke. An invalid value is handled as the default value.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci**Parameters**
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci| Name| Type                      | Mandatory| Description                                |
109e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ------------------------------------ |
110e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string | Yes  | Offset of the start point for drawing the stroke.<br>Default value: **0**|
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci### strokeLineCap
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_cistrokeLineCap(value: LineCapStyle)
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ciSets the cap style of the stroke.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci**Parameters**
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci| Name| Type                                             | Mandatory| Description                                            |
125e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------- | ---- | ------------------------------------------------ |
126e41f4b71Sopenharmony_ci| value  | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Yes  | Cap style of the stroke.<br>Default value: **LineCapStyle.Butt**|
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci### strokeLineJoin
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_cistrokeLineJoin(value: LineJoinStyle)
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ciSets the join style of the stroke. This attribute does not work for the **\<Ellipse>** component, which does not have corners.
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci**Parameters**
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci| Name| Type                                               | Mandatory| Description                                              |
141e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------- | ---- | -------------------------------------------------- |
142e41f4b71Sopenharmony_ci| value  | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Yes  | Join style of the stroke.<br>Default value: **LineJoinStyle.Miter**|
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci### strokeMiterLimit
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_cistrokeMiterLimit(value: number | string)
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ciSets the limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. This attribute does not take effect for the **\<Ellipse>** component, because it does not have a miter join.
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**Parameters**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci| Name| Type                      | Mandatory| Description                                          |
157e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ---------------------------------------------- |
158e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string | Yes  | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.<br>Default value: **4**|
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci### strokeOpacity
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_cistrokeOpacity(value: number | string | Resource)
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ciSets the stroke opacity. The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**Parameters**
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                      |
173e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | -------------------------- |
174e41f4b71Sopenharmony_ci| value  | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | Yes  | Stroke opacity.<br>Default value: **1**|
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci### strokeWidth
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_cistrokeWidth(value: Length)
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciSets the stroke width. If of the string type, this attribute cannot be set in percentage. A percentage is processed as 1 px.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**Parameters**
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci| Name| Type                        | Mandatory| Description                    |
189e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------ |
190e41f4b71Sopenharmony_ci| value  | [Length](ts-types.md#length) | Yes  | Stroke width.<br>Default value: **1**|
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci### antiAlias
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ciantiAlias(value: boolean)
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ciSpecifies whether anti-aliasing is enabled.
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci**Parameters**
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                 |
205e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------- |
206e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether anti-aliasing is enabled.<br>Default value: **true**|
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci## Example
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci```ts
211e41f4b71Sopenharmony_ci// xxx.ets
212e41f4b71Sopenharmony_ci@Entry
213e41f4b71Sopenharmony_ci@Component
214e41f4b71Sopenharmony_cistruct EllipseExample {
215e41f4b71Sopenharmony_ci  build() {
216e41f4b71Sopenharmony_ci    Column({ space: 10 }) {
217e41f4b71Sopenharmony_ci      // Draw a 150 x 80 ellipse.
218e41f4b71Sopenharmony_ci      Ellipse({ width: 150, height: 80 })
219e41f4b71Sopenharmony_ci      // Draw a 150 x 100 ellipse with blue strokes.
220e41f4b71Sopenharmony_ci      Ellipse()
221e41f4b71Sopenharmony_ci        .width(150)
222e41f4b71Sopenharmony_ci        .height(100)
223e41f4b71Sopenharmony_ci        .fillOpacity(0)
224e41f4b71Sopenharmony_ci        .stroke(Color.Blue)
225e41f4b71Sopenharmony_ci        .strokeWidth(3)
226e41f4b71Sopenharmony_ci    }.width('100%')
227e41f4b71Sopenharmony_ci  }
228e41f4b71Sopenharmony_ci}
229e41f4b71Sopenharmony_ci```
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci![en-us_image_0000001174104394](figures/en-us_image_0000001174104394.png)
232