wijjit.layout.bounds.Bounds

class wijjit.layout.bounds.Bounds(x, y, width, height)[source]

Represents the position and size of a UI element.

Parameters:
  • x (int) – Horizontal position (column), 0-indexed

  • y (int) – Vertical position (row), 0-indexed

  • width (int) – Width in characters

  • height (int) – Height in lines

Variables:
  • x (int) – Horizontal position

  • y (int) – Vertical position

  • width (int) – Width in characters

  • height (int) – Height in lines

__init__(x, y, width, height)
Parameters:
Return type:

None

Methods

__init__(x, y, width, height)

contains(x, y)

Check if a point is within these bounds.

intersect(other)

Return the overlapping region with another bounds.

overlaps(other)

Check if these bounds overlap with another bounds.

Attributes

area

Get the total area (width * height).

bottom

Get the bottom edge position (y + height).

right

Get the right edge position (x + width).

x

y

width

height

x: int
y: int
width: int
height: int
property right: int

Get the right edge position (x + width).

Returns:

Right edge column

Return type:

int

property bottom: int

Get the bottom edge position (y + height).

Returns:

Bottom edge row

Return type:

int

property area: int

Get the total area (width * height).

Returns:

Total area in characters

Return type:

int

contains(x, y)[source]

Check if a point is within these bounds.

Parameters:
  • x (int) – X coordinate to check

  • y (int) – Y coordinate to check

Returns:

True if the point is within bounds

Return type:

bool

overlaps(other)[source]

Check if these bounds overlap with another bounds.

Parameters:

other (Bounds) – The other bounds to check

Returns:

True if bounds overlap

Return type:

bool

intersect(other)[source]

Return the overlapping region with another bounds.

Parameters:

other (Bounds) – The other bounds to intersect with.

Returns:

The intersection rectangle, or None if the two do not overlap (no positive-area overlap).

Return type:

Bounds or None

__repr__()[source]

String representation of bounds.

Returns:

String representation

Return type:

str