- Index
- »
- fan.graphics
- »
- Rect
Rect
@Js
@Serializable { simple=true }
const class Rect : Obj
Represents the x,y coordinate and w,h size of a rectangle.
Construct with x, y, w, h as integers
Parse from comma or space separated string
Construct from a Point and Size instance
Construct with x, y, w, h
Width
Height
X coordinate
Y coordinate
Default instance is 0, 0, 0, 0
Return "x y w h"
Return true if x,y is inside the bounds of this rectangle
Get the w, h size of this rectangle
Return true if this rectangle intersects any portion of that rectangle
Get the x, y coordinate of this rectangle
Return if obj is same Rect value
Compute the intersection between this rectangle and that rectangle
Compute the union between this rectangle and that rectangle, which is the bounding box that exactly contains both rectangles
Return hash of x, y, w, and h
Bool contains(Point pt)
Return true if x,y is inside the bounds of this rectangle.
const static Rect : defVal
Default instance is 0, 0, 0, 0.
virtual Bool equals(Obj? obj)
Return if obj is same Rect value.
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.
const Float : h
Height
virtual Int hash()
Return hash of x, y, w, and h.
Rect intersection(Rect that)
Compute the intersection between this rectangle and that rectangle. If there is no intersection, then return defVal.
Bool intersects(Rect that)
Return true if this rectangle intersects any portion of that rectangle
new make(Float x, Float y, Float w, Float h)
Construct with x, y, w, h.
new makeInt(Int x, Int y, Int w, Int h)
Construct with x, y, w, h as integers.
new makePosSize(Point p, Size s)
Construct from a Point and Size instance
Point pos()
Get the x, y coordinate of this rectangle.
Size size()
Get the w, h size of this rectangle.
virtual Str toStr()
Return "x y w h"
Rect union(Rect that)
Compute the union between this rectangle and that rectangle, which is the bounding box that exactly contains both rectangles.
const Float : w
Width
const Float : x
X coordinate
const Float : y
Y coordinate