Documentation ¶
Index ¶
- type Number
- type Rect2D
- func (r *Rect2D[T]) Abs() *Rect2D[T]
- func (r *Rect2D[T]) GetArea() T
- func (r *Rect2D[T]) GetCenter() *vector.Vector2D[T]
- func (r *Rect2D[T]) GetPosition() *vector.Vector2D[T]
- func (r *Rect2D[T]) GetRandomPoint() *vector.Vector2D[T]
- func (r *Rect2D[T]) GetSize() *vector.Vector2D[T]
- func (r *Rect2D[T]) HasPoint(point *vector.Vector2D[T]) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
type Rect2D ¶
type Rect2D[T Number] struct { Position *vector.Vector2D[T] `json:"position"` Size *vector.Vector2D[T] `json:"size"` }
A 2D axis-aligned bounding box using floating-point coordinates. Represents an axis-aligned rectangle in a 2D space. It is defined by its position and size, which are Vector2D.
func New2D ¶
New2D constructs a new VRect2D from the given position and size. position is the rectangle start x and y size is the rectangle width and height
func (*Rect2D[T]) Abs ¶ added in v0.0.7
Abs returns a Rect2D equivalent to this rectangle, with its width and height modified to be non-negative values, and with its position being the top-left corner of the rectangle. E.g: Rect2D(25, 25, -100, -50) ~> Rect2D(-75, -25, 100, 50)
func (*Rect2D[T]) GetArea ¶
func (r *Rect2D[T]) GetArea() T
GetArea returns the rectangle's area. This is equivalent to size.x * size.y
func (*Rect2D[T]) GetCenter ¶
GetCenter returns the center point of the rectangle. This is the same as position + (size / 2.0).
func (*Rect2D[T]) GetPosition ¶ added in v0.0.6
GetPosition returns a vector with the starting point of the rectangle as x and y
func (*Rect2D[T]) GetRandomPoint ¶ added in v0.0.8
GetRandomPoint generates a random coordinates vector within the rectangle's bounds