win.rect - WIN

Class rect
Inherits from __classBase.

A rect object represents a rectangle, as x, y (left, top) coordinates, and width and height dimensions.

Properties
x number Rectangle's left position.
y
number Rectangle's top position.
width number Rectangle's width.
height number Rectangle's height.

Methods

See also API Reference, WIN.

win.rect:bound

rect:bound (rt)

Combines the object's coordinates with the given rectangle (the smallest rectangle that includes both).

Parameters
rt rect The rectangle object to combine.

Returns
none


Remarks


top


win.rect:clip

rect:clip (rt)

Clips the object's coordinates with those of the given rectangle (the overlapping rectangle).

Parameters
rt rect The rectangle object to clip the object.

Returns
none


Remarks
If the rectangles do not overlap the object is made empty.


top


win.rect:constructor

object rect:constructor (x, y, width, height)

Constructor for the rect class object.

Parameters
x
number/nil Initial x coordinate for the rect object.
y
number/nil Initial y coordinate for the rect object.
width number/nil Initial width dimension for the rect object.
height number/nil Initial height dimension for the rect object.

Returns
object rect The instantiated rect object.

Remarks
If any parameter is nil, zero is assumed. To construct an initially empty rectangle:
local rt = rect:new ()

top


win.rect:contains

result rect:contains (x, y)

Returns true if the rectangle contains the given point, false if not.

Parameters
x
number x coordinate of point to test.
y
number y coordinate of point to test.

Returns
result boolean true if the rectangle object contains the given point, false if not.

Remarks
The point coordinates must be from aligned with the rectangle's x, y coordinates within its width and height dimensions. If the rectangle object is empty false is returned.


top


win.rect:copy

rect:copy (rt)

Copies the given rectangle's coordinates to the object.

Parameters
rt rect The rect object to copy.

Returns
none


Remarks
If the source rectangle is empty, the object is made empty.


top


win.rect:empty

rect:empty ()

Makes the rectangle object empty.

Parameters
none


Returns
none


Remarks
All coordinates are set to zero.


top


win.rect:is_empty

result rect:is_empty ()

Returns true if the rect object is empty, false if not.

Parameters
none


Returns
result
boolean true if the rectangle is empty, false if not.

Remarks
A rectangle is empty if its width or height dimension is zero.


top


win.rect:offset

rect:offset (x, y)

Moves the rectangle by the given offset.

Parameters
x
number Offset value for the x coordinate.
y
number Offset value for the y coordinate.

Returns
none


Remarks
Either x or y may be negative.


top


win.rect:overlap

result rect:overlap (rt)

Returns true if any of the given rectangle overlaps with the object, false if not.

Parameters
rt rect The rectangle object to test.

Returns
result boolean true if overlaps, false if not.

Remarks
If either rectangle object is empty false is returned.


top


win.rect:unpack

x, y, width, height rect:unpack ()

Unpacks the rectangle object's coordinate values.

Parameters
none


Returns
x
number Rectangle's x coordinate.
y
number Rectangle's y coordinate.
width number Rectangle's width dimension.
height number Rectangle's height dimension.

Remarks


top


See also API Reference, WIN.