class

Rect

@Js
@Serializable { simple=true }
const class Rect : Obj

Represents the x,y coordinate and w,h size of a rectangle.

constructors makeInt

Construct with x, y, w, h as integers

fromStr

Parse from comma or space separated string

makePosSize

Construct from a Point and Size instance

make

Construct with x, y, w, h

fields w

Width

h

Height

x

X coordinate

y

Y coordinate

defVal

Default instance is 0, 0, 0, 0

methods toStr

Return "x y w h"

contains

Return true if x,y is inside the bounds of this rectangle

size

Get the w, h size of this rectangle

intersects

Return true if this rectangle intersects any portion of that rectangle

pos

Get the x, y coordinate of this rectangle

equals

Return if obj is same Rect value

intersection

Compute the intersection between this rectangle and that rectangle

union

Compute the union between this rectangle and that rectangle, which is the bounding box that exactly contains both rectangles

hash

Return hash of x, y, w, and h

contains Bool contains(Point pt)

Return true if x,y is inside the bounds of this rectangle.

defVal const static Rect : defVal

Default instance is 0, 0, 0, 0.

equals virtual Bool equals(Obj? obj)

Return if obj is same Rect value.

fromStr static new fromStr(Str s, Bool checked)

Parse from comma or space separated string. If invalid then throw ParseErr or return null based on checked flag.

h const Float : h

Height

hash virtual Int hash()

Return hash of x, y, w, and h.

intersection Rect intersection(Rect that)

Compute the intersection between this rectangle and that rectangle. If there is no intersection, then return defVal.

intersects Bool intersects(Rect that)

Return true if this rectangle intersects any portion of that rectangle

make new make(Float x, Float y, Float w, Float h)

Construct with x, y, w, h.

makeInt new makeInt(Int x, Int y, Int w, Int h)

Construct with x, y, w, h as integers.

makePosSize new makePosSize(Point p, Size s)

Construct from a Point and Size instance

pos Point pos()

Get the x, y coordinate of this rectangle.

size Size size()

Get the w, h size of this rectangle.

toStr virtual Str toStr()

Return "x y w h"

union Rect union(Rect that)

Compute the union between this rectangle and that rectangle, which is the bounding box that exactly contains both rectangles.

w const Float : w

Width

x const Float : x

X coordinate

y const Float : y

Y coordinate

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST