struct
Crame::Rect2
- Crame::Rect2
- Struct
- Value
- Object
Overview
A two-dimensional rectangle.
Defined in:
crame/rect2.crConstructors
-
.new(x : Float64, y : Float64, w : Float64, h : Float64)
Creates a new rectangle by setting its position with
xandyand its size withwandh. -
.new(position : Crame::Vector2, size : Crame::Vector2)
Creates a new rectangle given its position and size.
-
.new
Creates a new rectangle with its position and size equal to 0.
Instance Method Summary
-
#area : Float64
Returns the area of
self. -
#center : Vector2
Returns the center point of
self. -
#intersection(other : Rect2) : Rect2
Return the intersection between
selfandother. -
#intersects?(other : Rect2, borders : Bool = false) : Bool
Returns
trueifselfintersects withother,falseotherwise. -
#position : Vector2
The position of the rectangle.
-
#position=(position : Vector2)
The position of the rectangle.
-
#size : Vector2
The size of the rectangle.
-
#size=(size : Vector2)
The size of the rectangle.
-
#to_s(io : IO)
Same as
#inspect(io). -
#union(other : Rect2) : Rect2
Returns the smallest rectangle that contains
selfandother.
Constructor Detail
Creates a new rectangle by setting its position with x and y
and its size with w and h.
Creates a new rectangle given its position and size.
Instance Method Detail
Returns the center point of self.
NOTE This is equivalent to position + size / 2.
Return the intersection between self and other.
If no intersection is detected, this returns an empty rectangle instead.
Returns true if self intersects with other, false otherwise.
If borders is true, the edges of both rectangles are included as
potential intersection points.