ADOBE DIRECTOR 11.0
User Guide
119
Capture the current graphic contents of the Stage
•
Set a bitmap’s
picture
cast member property to the Stage’s
picture
property. For more information, see the
Scripting Reference topics in the Director Help Panel.
For example, the
member("Archive").picture = (the stage).picture
statement makes the current image
of the Stage the image for the bitmap cast member Archive.
Creating image objects
An image object can be either a self-contained set of image data or a reference to the image data of a cast member or
of the Stage. If an image object is created by referring to a cast member, the object contains a reference to the image
of the member. The following statement creates an image object that contains a reference to the image of the cast
member called Boat.
myImage = member("Boat").image
Because the image object
myImage
contains a reference to the cast member Boat, any changes you make to the object
are reflected in the cast member. These changes are also reflected in any sprites made from that cast member.
You can also create an image object that contains a reference to the graphic contents of the Stage as follows:
myImage = window("stage").image
Any changes to this image object are reflected on the Stage.
•
To create an image object that is a self-contained set of image data instead of a reference to a cast member, you
must tell the script what kind of image you want to create. You must provide the parameters that describe the size
and bit depth of the image you are creating.
The following statement creates an image object that contains a 640 x 480 pixel, 16-bit image:
myImage = image(640, 480, 16)
Editing image objects
After you create an image object, its data can be edited with a variety of scripting commands that are designed to
manipulate the pixels of the image. You can crop images, draw new pixels on them, copy sections of them, and work
with mask and alpha channel information. For more information, see the Scripting Reference topics in the Director
Help Panel.
Draw a line on an image object
•
Use the
draw()
method. You must specify the locations of each end of the line in addition to the line’s color.
The following statement draws a line on the previously created 640 x 480 image object
myImage
, running from 20
pixels inside the upper-left corner to 20 pixels inside the lower-right corner, and colors it blue:
myImage.draw(20, 20, 620, 460, rgb(0, 0, 255))
Draw a rectangle on an image object
•
Use the
fill()
method. You provide the same information as for the
draw
method, but Director draws a
rectangle instead of a line.
The following statement draws a red 40 x 40 pixel rectangle near the upper-left corner of the image object
myImage
:
myImage.fill(rect(20, 20, 60, 60), rgb(255, 0, 0))