ohos.arkui.shape

Note:

Currently in the beta phase.

Provides fundamental capabilities for drawing shapes.

Import Module

import kit.ArkUI.*

class BaseShape

public abstract class BaseShape {}

Description: The base class for shapes, providing basic properties and methods for graphical elements.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

func fill(?ResourceColor)

public func fill(color: ?ResourceColor): This

Description: Sets the fill color for the shape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
color ?ResourceColor Yes - The fill color of the shape.

Return Value:

Type Description
This Returns the current object.

func height(?Length)

public func height(height: ?Length): This

Description: Sets the height of the shape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
height ?Length Yes - The height of the shape.

Return Value:

Type Description
This Returns the current object.

func offset(?Length, ?Length)

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

Description: Sets the offset of the shape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
x ?Length Yes - Named parameter. The x-axis offset.
Default: 0.0.px.
y ?Length Yes - Named parameter. The y-axis offset.
Default: 0.0.px.

Return Value:

Type Description
This Returns the current object.

func size(?Length, ?Length)

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

Description: Sets the dimensions of the shape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length Yes - Named parameter. The width of the shape.
Default: 0.0.vp.
height ?Length Yes - Named parameter. The height of the shape.
Default: 0.0.vp.

Return Value:

Type Description
This Returns the current object.

func width(?Length)

public func width(width: ?Length): This

Description: Sets the width of the shape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length Yes - The width of the shape.

Return Value:

Type Description
This Returns the current object.

class CircleShape

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

Description: Circular shape used for the clipShape and maskShape interfaces.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parent Class:

init(?Length, ?Length)

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

Description: Constructor for CircleShape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length No None Named parameter. The width of the circle.
Default: 0.vp.
height ?Length No None Named parameter. The height of the circle.
Default: 0.vp.

class EllipseShape

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

Description: Elliptical shape used for the clipShape and maskShape interfaces.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parent Class:

init(?Length, ?Length)

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

Description: Constructor for EllipseShape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length No None Named parameter. The width of the ellipse.
Default: 0.vp.
height ?Length No None Named parameter. The height of the ellipse.
Default: 0.vp.

class PathShape

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

Description: Path used for the clipShape and maskShape interfaces.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parent Class:

init(?ResourceStr)

public init(commands!: ?ResourceStr = None)

Description: Constructor for PathShape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
commands ?ResourceStr No None Named parameter. Drawing commands for the path.
Default: "".
For more information, see the drawing commands supported by commands.

init(?Length, ?Length, ?ResourceStr)

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

Description: Constructor for PathShape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length Yes - Named parameter. The width of the path.
Default: 0.vp.
height ?Length Yes - Named parameter. The height of the path.
Default: 0.vp.
commands ?ResourceStr No None Named parameter. The path commands.
Default: "".
For more information, see the drawing commands supported by commands.

class RectShape

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

Description: Rectangular shape used for the clipShape and maskShape interfaces.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parent Class:

init(?Length, ?Length)

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

Description: Constructor for RectShape.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
width ?Length No None Named parameter. The width of the rectangle.
Default: 0.vp.
height ?Length No None Named parameter. The height of the rectangle.
Default: 0.vp.

func radius(?Length)

public func radius(value: ?Length): This

Description: Sets the corner radius of the rectangle.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
value ?Length Yes - The corner radius of the rectangle.
Default: 0.vp.

Return Value:

Type Description
This Returns the current object.

func radiusHeight(?Length)

public func radiusHeight(value: ?Length): This

Description: Sets the vertical corner radius of the rectangle.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
value ?Length Yes - The vertical corner radius of the rectangle.
Default: 0.vp.

Return Value:

Type Description
This Returns the current object.

func radiusWidth(?Length)

public func radiusWidth(value: ?Length): This

Description: Sets the horizontal corner radius of the rectangle.

System Capability: SystemCapability.ArkUI.ArkUI.Full

Since: 22

Parameters:

Parameter Type Required Default Description
value ?Length Yes - The horizontal corner radius of the rectangle.
Default: 0.vp.

Return Value:

Type Description
This Returns the current object.