geometry

Classes representing geometric coordinates and shapes.

Point

class tanmatsu.geometry.Point(x: int, y: int)

Coordinates on a 2D plane.

Variables
  • x (int) – x coordinate.

  • y (int) – y coordinate.

set(x: int, y: int)

Set the coordinates to x, y.

duplicate() Self

Returns a copy of the coordinates.

__eq__(other: Point) bool

Whether this point is equal to point other (compare-by-value).

__str__() str

Returns a string representation of the point.

Dimensions

class tanmatsu.geometry.Dimensions(w: int, h: int)

Dimensions on a 2D plane.

Variables
  • w (int) – width (w dimension).

  • h (int) – height (h dimension).

set(w: int, h: int)

Set the dimensions to w, h.

duplicate() Self

Returns a copy of the dimensions.

__eq__(other: Dimensions) bool

Whether the width and height of this dimensions object is equal to the width and height of the dimensions object other.

__lt__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether the width and height of this dimensions object are both less than the width and height of object other.

__le__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether the width and height of this dimensions object are both less than or equal to the width and height of object other.

__gt__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether the width and height of this dimensions object are both greater than the width and height of object other.

__ge__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether the width and height of this dimensions object are both greater than or equal to the width and height of object other.

__str__() str

Returns a string representation of the dimensions.

Rectangle

class tanmatsu.geometry.Rectangle(x: int, y: int, w: int, h: int)

Coordinates and dimensions on a 2D plane.

Variables
  • x (int) – x coordinate.

  • y (int) – y coordinate.

  • w (int) – width (w dimension).

  • h (int) – height (h dimension).

property x1

Alias of x.

property y1

Alias of y.

property x2: int

The coordinate at x + w - 1. I.e., the far x coordinate.

property y2: int

The coordinate at y + h - 1. I.e., the far y coordinate.

intersects(other: Rectangle) bool

Whether this rectangle intersects with rectangle other.

containsp(other: Point) bool

Whether this rectangle contains point other.

containsr(other: Rectangle) bool

Whether this rectangle contains rectangle other.

duplicate() Self

Returns a copy of this rectangle.

top_left() Point

Returns the near x and y. In other words, the origin point (top left) of the rectangle.

top_right() Point

Returns the far x, and the near y. In other words, the top right of the rectangle.

bottom_left() Point

Returns the near x, and the far y. In other words, the bottom left of the rectangle.

bottom_right() Point

Returns the far x and y. In other words, the end point (bottom right) of the rectangle.

dimensions() Dimensions

Returns the dimensions of the rectangle.

__eq__(other: Rectangle) bool

Whether this rectangle’s position in space and dimensions are equal to rectangle other.

__lt__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether this rectangle’s width and height are both less than the width and height of object other.

__le__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether this rectangle’s width and height are both less than or equal to the width and height of object other.

__gt__(other: tanmatsu.geometry.Rectangle | tanmatsu.geometry.Dimensions) bool

Whether this rectangle’s width and height are both greater than or equal to the width and height of object other.

__and__(other: Rectangle) Rectangle

Returns the rectangle that represents the overlap between this rectangle and rectangle other.

__str__() str

Returns a string representation of the rectangle.