Skip to content

UI Anchor

Anchor

Bases: IntEnum

Relative position of a UI element from a specific point.

BOTTOM class-attribute instance-attribute

BOTTOM: int = auto()

Position is based on the bottom area of this element.

BOTTOM_LEFT class-attribute instance-attribute

BOTTOM_LEFT: int = auto()

Position is based on the bottom-left area of this element.

BOTTOM_RIGHT class-attribute instance-attribute

BOTTOM_RIGHT: int = auto()

Position is based on the bottom-right area of this element.

CENTER class-attribute instance-attribute

CENTER: int = auto()

Position is based on the center area of this element.

LEFT class-attribute instance-attribute

LEFT: int = auto()

Position is based on the left area of this element.

RIGHT class-attribute instance-attribute

RIGHT: int = auto()

Position is based on the right area of this element.

TOP class-attribute instance-attribute

TOP: int = auto()

Position is based on the top area of this element.

TOP_LEFT class-attribute instance-attribute

TOP_LEFT: int = auto()

Position is based on the top-left area of this element.

TOP_RIGHT class-attribute instance-attribute

TOP_RIGHT: int = auto()

Position is based on the top-right area of this element.

calculate_position staticmethod

calculate_position(
    position: IntVector2, size: IntVector2, anchor: Anchor
) -> IntVector2

Calculate the relative position of an element based on an anchor point.

PARAMETER DESCRIPTION
position

The X, Y relative position.

TYPE: IntVector2

size

The X, Y relative size.

TYPE: IntVector2

anchor

The anchor point to calculate to.

TYPE: Anchor

RETURNS DESCRIPTION
IntVector2

The calculated position relative to the anchor point.

RAISES DESCRIPTION
TypeError
  • Parameters position and size aren't IntVector2.
  • Parameter anchor isn't an Anchor.