Represents a color that can be chosen by the user in different kinds (RGB, HSV, HSL, grayscale, indexed).
Don't confuse this color with the app.pixelColor which is used to put/get pixels to/from an image.
local c
c = Color{ r=255, g=255, b=255, a=255 }
c = Color{ h=360.0, s=1.0, v=1.0, a=255 }
c = Color{ h=360.0, s=1.0, l=1.0, a=255 }
c = Color{ red=255, green=255, blue=255, alpha=255 }
c = Color{ hue=360.0, saturation=1.0, value=1.0, alpha=255 }
c = Color{ hue=360.0, saturation=1.0, lightness=1.0, alpha=255 }
c = Color{ gray=255, alpha=255 }
c = Color{ index=integer }
c = Color{ tile=integer }
c = Color(integer)- If the
alphaargument is not specified, it is 255 by default (opacity = 100%). - The
Color{ index=integer }returns the color at the specified index from the palette. - The
Color{ tile=integer }returns a special "tile color" at the specified index from the current tileset. This "tile color" can be used to pass tiles into parameters that require the color object (e.g:app.useTool{color=Color{tile=integer}}). - The
Color(integer)constructor receives a pixel color and the integer is interpreted depending on the active sprite.
local c = Color{ r=0, g=0, b=0, a=128 }
assert(c.alpha == 128)local c = Color{ r=255, g=128, b=32 }
assert(c.red == 255)
assert(c.green == 128)
assert(c.blue == 32)
c.red = 20
c.green = 40
c.blue = 255Get/sets red/green/blue components of the color.
local c = Color{ h=45, s=0.5, v=0.2 }
assert(c.hsvHue == 45)
assert(c.hsvSaturation == 0.5)
assert(c.hsvValue == 0.2)Gets/sets the HSV hue or HSL hue depending on the kind of color.
Gets/sets the HSV saturation or HSL saturation depending on the kind of color.
Gets/sets the HSV value.
Gets/sets the HSL lightness.
local c = Color(index)
oldIndex = c.index
c.index = newIndexGets or sets the palette index related to this color. If the color is not an index, i.e. it's RGB/HSL/HSV, the closest palette index of the current palette (the palette of the active sprite) that matches the RGB/HSL/HSV values will be returned.
local c = Color{ r=200, g=100, b=0, a=255 }
assert(c.rgbaPixel == app.pixelColor.rgba(200, 100, 0, 255))Returns the pixel color which is equivalent to the RGBA values of this color.
Returns the pixel color which is equivalent to the gray+alpha values of this color.