Ir para o conteúdo principal
Version: latest - a1.7.0 ⚖️

Color

A color composed of components (R, G, B, A) with floating point precision.

info

Tip: This structure is Open Sourced at https://github.com/nanos-world/nanos-world-lua-lib. Feel free to push merge requests and suggest changes!

tip

Note: This structure supports +, -, *, /, ==, and tostring operations.

Usage

local grey_color = Color(0.5, 0.5, 0.5, 1)

Properties

ValueNameDescription
numberRRed color percentage (0-1)
numberGGreen color percentage (0-1)
numberBBlue color percentage (0-1)
numberAAlpha transparency percentage (0-1)

Static Properties

ValueName
Color(1, 1, 1)Color.WHITE
Color(0, 0, 0)Color.BLACK
Color(0, 0, 0, 0)Color.TRANSPARENT
Color(1, 0, 0)Color.RED
Color(0, 1, 0)Color.GREEN
Color(0, 0, 1)Color.BLUE
Color(1, 1, 0)Color.YELLOW
Color(0, 1, 1)Color.CYAN
Color(1, 0, 1)Color.MAGENTA
Color(1, 0.5, 0)Color.ORANGE
Color(0.5, 1, 1)Color.CHARTREUSE
Color(0, 1, 0.5)Color.AQUAMARINE
Color(0, 0.5, 1)Color.AZURE
Color(0.5, 0, 1)Color.VIOLET
Color(1, 0, 0.5)Color.ROSE

Static Functions

ReturnsNameDescription
ColorColor.RandomPalette()Returns a random color from Color Palette
ColorColor.Random()Returns a random color from all color scope
ColorColor.FromRGBA(number r, number g, number b, number a)Returns the color from 0-255 range values
ColorColor.FromCYMK(number c, number y, number m, number k, number a)Returns a color from the CYMK format
ColorColor.FromHSL(number h, number s, number l)Returns a color from the HSL format
ColorColor.FromHSV(number h, number s, number v)Returns a color from the HSV format
ColorColor.FromHEX(string hex)Returns a color from the Hexadecimal format

Functions

ReturnsNameDescription
stringToHEX()Gets the Hexadecimal representation of this Color