Lingo Dictionary > A-C > color() |
![]() ![]() ![]() |
color()
Syntax
color(
#rgb, redValue, greenValue, blueValue
)
color(
#paletteIndex, paletteIndexNumber
)
rgb(
rgbHexString
)
rgb(
redValue, greenValue, blueValue
)
paletteIndex(
paletteIndexNumber
)
Description
Function and data type; determines an object's color as either RGB or 8-bit palette index values. These are the same values as those used in the color
member and color
sprite properties, the bgColor
member and bgColor
sprite properties, and the bgColor
Stage property.
The color
function allows for either 24-bit or 8-bit color values to be manipulated as well as applied to cast members, sprites, and the Stage.
For RGB values, each color component has a range from 0 to 255, and all other values are truncated. For paletteIndex
types, an integer from 0 to 255 is used to indicate the index number in the current palette, and all other values are truncated.
Example
This statement performs a math operation:
palColorObj = paletteIndex(20) put palColorObj -- paletteIndex(20) put palColorObj / 2 -- paletteIndex(10)
Example
This statement converts one color type to another type:
newColorObj = color(#rgb, 155, 0, 75) put newColorObj -- rgb(155, 0, 75) newColorObj.colorType = #paletteIndex put newColorObj -- paletteIndex(106)
Example
This statement obtains the hexadecimal representation of a color regardless of its type:
someColorObj = color(#paletteIndex, 32) put someColorObj.hexString() -- "#FF0099"
Example
This statement determines individual RGB components and the paletteIndex
value of a color regardless of its type:
newColorObj = color(#rgb, 155, 0, 75) put newColorObj.green -- 0 put newColorObj.paletteIndex -- 106 newColorObj.green = 100 put newColorObj.paletteIndex -- 94 put newColorObj -- rgb(155, 100, 75) newColorObj.paletteIndex = 45 put newColorObj -- paletteIndex(45)
Example
This statement changes the color of the fourth through the seventh characters of text member myQuotes:
member("myQuotes").char[4..7].color = rgb(200, 150, 75)
Example
This Lingo displays the color of sprite 6 in the Message window, and then sets the color of sprite 6 to a new RGB value:
"put sprite(6).color -- rgb( 255, 204, 102 ) sprite(6).color = rgb(122, 98, 210)"
Note: Setting the paletteIndex
value of an RGB color type changes colorType
to paletteIndex
. Setting the RGB color type of a paletteIndex
color sets its colorType
value to RGB.
See also
![]() ![]() ![]() |