Lingo Dictionary > O-R > rect() |
![]() ![]() ![]() |
rect()
Syntax
rect(
left
,
top
,
right
,
bottom
)
rect(
point1
,
point2
)
Description
Function and data type; defines a rectangle.
The rect(
left, top, right, bottom
)
format defines a rectangle whose sides are specified by left
, top
, right
, and bottom
. The left
and right
values specify numbers of pixels from the left edge of the Stage. The top
and bottom
values specify numbers of pixels from the top of the Stage.
The rect(
point1, point2
)
format defines a rectangle that encloses the points specified by point1
and point2
.
You can refer to rectangle components by list syntax or property syntax. For example, the following two phrases are equivalent:
targetWidth = targetRect.right - targetRect.left targetWidth = targetRect[3] - targetRect[1]
You can perform arithmetic operations on rectangles. If you add a single value to a rectangle, Lingo adds it to each element in the rectangle.
To see an example of rect()
used in a completed movie, see the Imaging movie in the Learning\Lingo Examples folder inside the Director application folder.
Example
This statement sets the variable newArea
to a rectangle whose left side is at 100, top is at 150, right side is at 300, and bottom is at 400 pixels:
set newArea = rect(100, 150, 300, 400)
Example
This statement sets the variable newArea
to the rectangle defined by the points firstPoint
and secondPoint
. The coordinates of firstPoint
are (100, 150); the coordinates of secondPoint
are (300, 400). Note that this statement creates the same rectangle as the one created in the previous example:
put rect(firstPoint, secondPoint)
Example
These statements add and subtract values for rectangles:
put rect(0,0,100,100) + rect(30, 55, 120, 95) -- rect(30, 55, 220, 195) put rect(0,0,100,100) - rect(30, 55, 120, 95) -- rect(-30, -55, -20, 5)
Example
This statement adds 80 to each coordinate in a rectangle:
put rect(60, 40, 120, 200) + 80 -- rect(140, 120, 200, 280)
Example
This statement divides each coordinate in a rectangle by 3:
put rect(60, 40, 120, 200) / 3 -- rect(20, 13, 40, 66)
See also
![]() ![]() ![]() |