Rect

2D rectangle

Constructors

this
this(int x0, int y0, int x1, int y1)

constructs rectangle using left, top, right, bottom coordinates

Members

Functions

expand
void expand(int dx, int dy)

expand rectangle dimensions

intersect
bool intersect(Rect rc)

updates this rect to intersection with rc, returns true if result is non empty

intersects
bool intersects(Rect rc)

returns true if this rect has nonempty intersection with rc

isInsideOf
bool isInsideOf(Rect rc)

this rectangle is completely inside rc

isPointInside
bool isPointInside(Point pt)

returns true if point is inside of this rectangle

isPointInside
bool isPointInside(int x, int y)

returns true if point is inside of this rectangle

moveBy
void moveBy(int deltax, int deltay)

translate rectangle coordinates by (x,y) - add deltax to x coordinates, and deltay to y coordinates

moveToFit
void moveToFit(ref Rect rc)

moves this rect to fit rc bounds, retaining the same size

offset
void offset(int dx, int dy)

add offset to horizontal and vertical coordinates

setMax
void setMax(Rect rc)

for all fields, sets this.field to rc.field if rc.field > this.field

shrink
void shrink(int dx, int dy)

shrink rectangle dimensions

Properties

empty
bool empty [@property getter]

returns true if rectangle is empty (right <= left || bottom <= top)

height
int height [@property getter]

returns height of rectangle (bottom - top)

middle
Point middle [@property getter]

returns middle point

middlex
int middlex [@property getter]

returns average of left, right

middley
int middley [@property getter]

returns average of top, bottom

width
int width [@property getter]

returns width of rectangle (right - left)

Variables

bottom
int bottom;

y coordinate of bottom right corner

left
int left;

x coordinate of top left corner

right
int right;

x coordinate of bottom right corner

top
int top;

y coordinate of top left corner

Meta