ts-drawing-components-ellipse.md 2.2 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 30
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.

| Name| Type| Default Value| Mandatory| Description|
Z
zengyawen 已提交
31
| -------- | -------- | -------- | -------- | -------- |
E
ester.zhou 已提交
32 33 34
| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No| Color of the fill area.|
| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Opacity of the fill area.|
| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No|Stroke color.|
E
ester.zhou 已提交
35 36 37 38 39
| strokeDashArray | Array&lt;Length&gt; | [] | No| Stroke dash.|
| strokeDashOffset | number \| string | 0 | No| Offset of the start point for drawing the stroke.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | No| Cap style of the stroke.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | No| Join style of the stroke.|
| strokeMiterLimit | number \| string | 4 | No| Limit value when the sharp angle is drawn as a miter.|
E
ester.zhou 已提交
40
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Stroke opacity.|
E
ester.zhou 已提交
41 42
| strokeWidth | Length | 1 | No| Stroke width.|
| antiAlias | boolean | true | No| 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 53
@Entry
@Component
struct EllipseExample {
  build() {
    Flex({ justifyContent: FlexAlign.SpaceAround }) {
E
ester.zhou 已提交
54
      // Draw an ellipse in a 150 x 80 rectangle.
Z
zengyawen 已提交
55
      Ellipse({ width: 150, height: 80 })
E
ester.zhou 已提交
56
      // Draw an ellipse in a 150 x 80 rectangle.
Z
zengyawen 已提交
57 58 59 60 61 62
      Ellipse().width(150).height(80)
    }.width('100%').margin({ top: 5 })
  }
}
```

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