271
Examples
This statement identifies the position of the value 12 in the linear list Answers, which consists of
[10, 12, 15, 22]:
put Answers.getOne(12)
The result is 2, because 12 is the second value in the list.
This statement identifies the property associated with the value 12 in the property list Answers,
which consists of [#a:10, #b:12, #c:15, #d:22]:
put Answers.getOne(12)
The result is #b, which is the property associated with the value 12.
See also
getPos()
getPixel()
Syntax
imageObject
.getPixel(
x
,
y
{,
#integer
})
imageObject
.getPixel(point(
x
,
y
) {,
#integer
})
Description
This function returns the color value of the pixel at the specified point in the given image object.
This value is normally returned as an indexed or RGB color object, depending on the bit depth
of the image.
If you include the optional parameter value
#integer
, however, it’s returned as a raw number. If
you’re setting a lot pixels to the color of another pixel, it’s faster to set them as raw numbers. Raw
integer color values are also useful because they contain alpha layer information as well as color
when the image is 32-bit. The alpha channel information can be extracted from the raw integer
by dividing the integer by 2^8+8+8.
GetPixel()
returns 0 if the given pixel is outside the specified image object.
Examples
These statements get the color of the pixel at point (90, 20) in member Happy and set sprite 2 to
that color:
myColor=member("Happy").image.getPixel(90, 20)
sprite(2).color=myColor
This statement sets the variable alpha to the alpha channel value of the point (25, 33) in the 32-
bit image object myImage:
alpha = myImage.getPixel(25, 33, #integer) / power(2, 8+8+8)
See also
depth, color(), setPixel(), power()
Summary of Contents for DIRECTOR MX-LINGO DICTIONARY
Page 1: ...Lingo Dictionary Macromedia Director MX...
Page 756: ...Index 756...