User Guide

530
rect (camera)
Syntax
sprite(whichSprite).camera(whichCamera).rect
Description
3D camera property; allows you to get or set the rectangle that controls the size and position of
the camera. This rectangle is analogous to the rectangle you see through the eyepiece of a real
camera.
The default value for the rect property for all cameras rect(0,0,1,1) which makes them invisible
until you change the setting. However, when
sprite.camera(1) is rendered, its rect is reset to
rect(0, 0, sprite(whichSprite).width, sprite(whichSprite).height) so that the camera fills the
screen. All camera rect coordinates are given relative to the top left corner of the sprite.
Note that if
whichCamera is greater than 1, the rect is not scaled when the sprite is scaled, so it will
be necessary to manage that in Lingo if desired.
When
whichCamera is greater than 1, the rect.top and rect.left properties must be greater than or
equal to the
rect.top and rect.left settings for sprite.camera(1).
Example
This statement sets the rect of the default camera of sprite 5 to rect(0, 0, 200, 550):
sprite(5).camera.rect = rect(0, 0, 200, 550)
See also
cameraPosition, cameraRotation
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.