type

Rect

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

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

constructors

fromStr

Parse from comma or space separated string.

make

Construct with x, y, w, h.

makeInt

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

makePosSize

Construct from a Point and Size instance

fields

defVal

Default instance is 0, 0, 0, 0.

h

Height

w

Width

x

X coordinate

y

Y coordinate

methods

contains

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

equals

Return if obj is same Rect value.

hash

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

intersection

Compute the intersection between this rectangle and that rectangle.

intersects

Return true if this rectangle intersects any portion of that rectangle

pos

Get the x, y coordinate of this rectangle.

size

Get the w, h size of this rectangle.

toStr

Return "x y w h"

union

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

Slot Details

contains

src Bool contains(Point pt)

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

defVal

src const static Rect defVal := Rect.<ctor>(0.0, 0.0, 0.0, 0.0)

Default instance is 0, 0, 0, 0.

equals

src virtual override Bool equals(Obj? obj)

Return if obj is same Rect value.

fromStr

src static new fromStr(Str s, Bool checked := true)

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

h

src const Float h

Height

hash

src virtual override Int hash()

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

intersection

src Rect intersection(Rect that)

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

intersects

src Bool intersects(Rect that)

Return true if this rectangle intersects any portion of that rectangle

make

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

Construct with x, y, w, h.

makeInt

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

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

makePosSize

src new makePosSize(Point p, Size s)

Construct from a Point and Size instance

pos

src Point pos()

Get the x, y coordinate of this rectangle.

size

src Size size()

Get the w, h size of this rectangle.

toStr

src virtual override Str toStr()

Return "x y w h"

union

src Rect union(Rect that)

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

w

src const Float w

Width

x

src const Float x

X coordinate

y

src const Float y

Y coordinate