harmony 鸿蒙Ellipse

2022-08-09 浏览 (866)

Ellipse

The <Ellipse> component is used to draw an ellipse.

NOTE

This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.

Child Components

Not supported

APIs

Ellipse(options?: {width?: string|number, height?: string|number})

Since API version 9, this API is supported in ArkTS widgets.

Parameters

NameTypeMandatoryDescription
widthstring |numberNoWidth.
Default value: 0
NOTE
An invalid value is handled as the default value.
heightstring |numberNoHeight.
Default value: 0
NOTE
An invalid value is handled as the default value.

Attributes

In addition to the universal attributes, the following attributes are supported.

NameTypeDefault ValueDescription
fillResourceColorColor.BlackColor of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
An invalid value is handled as the default value.
fillOpacitynumber |string |Resource1Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
An invalid value is handled as the default value.
strokeResourceColor-Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
If the value is invalid, no stroke will be drawn.
strokeDashArrayArray<Length>[]Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
An invalid value is handled as the default value.
strokeDashOffsetnumber |string0Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
An invalid value is handled as the default value.
strokeLineCapLineCapStyleLineCapStyle.ButtCap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
strokeLineJoinLineJoinStyleLineJoinStyle.MiterJoin style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
This attribute does not work for the <ellipse> component, which does not have corners.
strokeMiterLimitnumber |string4Limit on the ratio of the miter length to the value of strokeWidth used to draw a miter join.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
This attribute does not take effect for the <Ellipse> component, because it does not have a miter join.
strokeOpacitynumber |string |Resource1Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
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.
strokeWidthLength1Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
NOTE
The value cannot be a percentage.
An invalid value is handled as the default value.
antiAliasbooleantrueWhether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.

Example

// xxx.ets
@Entry
@Component
struct EllipseExample {
  build() {
    Column({ space: 10 }) {
      // Draw a 150 x 80 ellipse.
      Ellipse({ width: 150, height: 80 })
      // Draw a 150 x 100 ellipse with blue strokes.
      Ellipse()
        .width(150)
        .height(100)
        .fillOpacity(0)
        .stroke(Color.Blue)
        .strokeWidth(3)
    }.width('100%')
  }
}

en-us_image_0000001174104394

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkTS-based Declarative Development Paradigm

harmony 鸿蒙@ohos.multimedia.avCastPicker (AVCastPicker)

harmony 鸿蒙Property Animation

harmony 鸿蒙Enums

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙CalendarPicker

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/2f8eabc89251487cb81509bef763b087