ohos.arkui.shape(形状)

说明:

当前为Beta阶段。

提供绘制图形的基础能力。

导入模块

import kit.ArkUI.*

class BaseShape

public abstract class BaseShape {}

功能: 图形基类,提供图形的基本属性和方法。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

func fill(?ResourceColor)

public func fill(color: ?ResourceColor): This

功能: 设置填充区域的颜色。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
color ?ResourceColor - 填充区域的颜色。

func height(?Length)

public func height(height: ?Length): This

功能: 设置图形高度。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
height ?Length - 图形高度。

func offset(?Length, ?Length)

public func offset(x!: ?Length, y!: ?Length): This

功能: 设置图形偏移。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
x ?Length - 命名参数。 x轴偏移。
初始值:0.0.px。
y ?Length - 命名参数。 y轴偏移。
初始值:0.0.px。

func size(?Length, ?Length)

public func size(width!: ?Length, height!: ?Length): This

功能: 设置图形尺寸。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length - 命名参数。 图形宽度。
初始值:0.0.vp。
height ?Length - 命名参数。 图形高度。
初始值:0.0.vp。

func width(?Length)

public func width(width: ?Length): This

功能: 设置图形宽度。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length - 图形宽度。

class CircleShape

public class CircleShape <: BaseShape {
    public init(width!: ?Length = None, height!: ?Length = None)
}

功能: 用于clipShapemaskShape接口的圆形形状。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

父类型:

init(?Length, ?Length)

public init(width!: ?Length = None, height!: ?Length = None)

功能: CircleShape的构造函数。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length None 命名参数。 圆形宽度。
初始值:0.vp。
height ?Length None 命名参数。 圆形高度。
初始值:0.vp。

class EllipseShape

public class EllipseShape <: BaseShape {
    public init(width!: ?Length = None, height!: ?Length = None)
}

功能: 用于clipShapemaskShape接口的椭圆形状。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

父类型:

init(?Length, ?Length)

public init(width!: ?Length = None, height!: ?Length = None)

功能: EllipseShape的构造函数。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length None 命名参数。 椭圆形宽度。
初始值:0.vp。
height ?Length None 命名参数。 椭圆形高度。
初始值:0.vp。

class PathShape

public class PathShape <: BaseShape {
    public init(commands!: ?ResourceStr = None)
    public init(width!: ?Length, height!: ?Length, commands!: ?ResourceStr = None)
}

功能: 用于clipShapemaskShape接口的路径。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

父类型:

init(?ResourceStr)

public init(commands!: ?ResourceStr = None)

功能: PathShape的构造函数。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
commands ?ResourceStr None 命名参数。 路径的绘制指令。
初始值:""。
更多说明请参考commands支持的绘制命令

init(?Length, ?Length, ?ResourceStr)

public init(width!: ?Length, height!: ?Length, commands!: ?ResourceStr = None)

功能: PathShape的构造函数。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length - 命名参数。 路径宽度。
初始值:0.vp。
height ?Length - 命名参数。 路径高度。
初始值:0.vp。
commands ?ResourceStr None 命名参数。 路径命令。
初始值:""。
更多说明请参考commands支持的绘制命令

class RectShape

public class RectShape <: BaseShape {
    public init(width!: ?Length = None, height!: ?Length = None)
}

功能: 用于clipShapemaskShape接口的矩形形状。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

父类型:

init(?Length, ?Length)

public init(width!: ?Length = None, height!: ?Length = None)

功能: RectShape的构造函数。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
width ?Length None 命名参数。 矩形宽度。
初始值:0.vp。
height ?Length None 命名参数。 矩形高度。
初始值:0.vp。

func radius(?Length)

public func radius(value: ?Length): This

功能: 设置矩形圆角半径。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
value ?Length - 矩形圆角半径。
初始值:0.vp。

func radiusHeight(?Length)

public func radiusHeight(value: ?Length): This

功能: 设置矩形垂直圆角半径。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
value ?Length - 矩形垂直圆角半径。
初始值:0.vp。

func radiusWidth(?Length)

public func radiusWidth(value: ?Length): This

功能: 设置矩形水平圆角半径。

系统能力: SystemCapability.ArkUI.ArkUI.Full

起始版本: 22

参数:

参数名 类型 必填 默认值 说明
value ?Length - 矩形水平圆角半径。
初始值:0.vp。