Bitmaps
223
Editing image objects
After you create an image object, its data can be edited with a variety of Lingo 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 individual commands in the Lingo Dictionary.
To draw a line on an image object:
•
Use the
draw()
command. You must specify the locations of each end of the line as well as 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))
To draw a rectangle on an image object:
•
Use the
fill()
command. You provide the same information as for the
draw
command, 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))
To determine the color of an individual pixel of an image object or set that pixel’s color:
•
Use the
getPixel
or
setPixel
command.
To copy part or all of an image object into a different image object:
•
Use the
copyPixels()
command, which requires you to specify the image from which you are
copying, the rectangle to which you are copying the pixels, and the rectangle from which to
copy the pixels in the source image.
The following statement copies a 40 x 40 rectangle from the upper left area of the image object
myImage
and puts the pixels into a 40 x 40 rectangle at the lower right of the 300 x 300 pixel
object called
myNewImage
:
myNewImage.copyPixels(myImage, rect(260, 260, 300, 300), rect(0, 0, 40, 40))
When using
copyPixels()
, you can specify optional parameters that tell Lingo to modify the
pixels you are copying before drawing them into the destination rectangle. You can apply blends
and inks, change the foreground or background colors, specify masking operations, and more.
You specify these operations by adding a property list at the end of the
copyPixels()
command.
The following statement performs the same operation as the previous example and tells Lingo to
use the Reverse ink when rendering the pixels into the destination rectangle:
myNewImage.copyPixels(myImage, rect(260, 260, 300, 300), rect(0, 0, 40, 40),
[#ink: #reverse])
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...