ts-drawing-components-ellipse.md 2.4 KB
Newer Older
Z
zengyawen 已提交
1
# Ellipse
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3
The **\<Ellipse>** component is used to draw an ellipse.
Z
zengyawen 已提交
4

E
ester.zhou 已提交
5 6 7
>  **NOTE**
>
>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
8 9 10


## Child Components
Z
zengyawen 已提交
11

E
ester.zhou 已提交
12
Not supported
Z
zengyawen 已提交
13 14


Z
zengyawen 已提交
15 16
## APIs

E
ester.zhou 已提交
17
Ellipse(options?: {width?: string | number, height?: string | number})
Z
zengyawen 已提交
18

E
ester.zhou 已提交
19
**Parameters**
Z
zengyawen 已提交
20

E
ester.zhou 已提交
21 22 23 24
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| width | string \| number | No| Width.<br>Default value: **0**|
| height | string \| number | No| Height.<br>Default value: **0**|
Z
zengyawen 已提交
25 26 27

## Attributes

E
ester.zhou 已提交
28 29
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.

E
ester.zhou 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42
| Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- |
| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.|
| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.|
| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.|
| strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes. |
| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.|
| strokeMiterLimit | number \| string | 4 | Limit value when the sharp angle is drawn as a miter.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.<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.|
| strokeWidth | Length | 1 | Stroke width.|
| antiAlias | boolean | true | Whether anti-aliasing is enabled.|
Z
zengyawen 已提交
43 44 45 46


## Example

Mr-YX's avatar
Mr-YX 已提交
47
```ts
E
ester.zhou 已提交
48
// xxx.ets
Z
zengyawen 已提交
49 50 51 52
@Entry
@Component
struct EllipseExample {
  build() {
E
ester.zhou 已提交
53 54
    Column({ space: 10 }) {
      // Draw a 150 x 80 ellipse.
Z
zengyawen 已提交
55
      Ellipse({ width: 150, height: 80 })
E
ester.zhou 已提交
56 57 58 59 60 61 62 63
      // Draw a 150 x 100 ellipse with blue strokes.
      Ellipse()
        .width(150)
        .height(100)
        .fillOpacity(0)
        .stroke(Color.Blue)
        .strokeWidth(3)
    }.width('100%')
Z
zengyawen 已提交
64 65 66 67
  }
}
```

E
ester.zhou 已提交
68
![en-us_image_0000001174104394](figures/en-us_image_0000001174104394.png)