Color
Create and manipulate colors
Color represents RGBA colors with support for hex notation and dynamic colors.
Use Color to:
Examples
let red = new Color("#FF0000");
let semiTransparent = new Color("#00FF00", 0.5);let blue = Color.blue();
let gray = Color.gray();let dynamic = Color.dynamic(Color.white(), Color.black());Methods
init
Create a color from hex string
Supports formats: "#RGB", "#RRGGBB", "#RRGGBBAA"
init(hex, alpha): voidhex- Hex color stringalpha- Optional alpha value (0.0-1.0)
Example:
new Color("#FF0000", 0.5)getHex
Get hex string representation
getHex(): stringExample:
color.hexgetRed
Get red component (0.0-1.0)
getRed(): numberExample:
color.redgetGreen
Get green component (0.0-1.0)
getGreen(): numberExample:
color.greengetBlue
Get blue component (0.0-1.0)
getBlue(): numberExample:
color.bluegetAlpha
Get alpha component (0.0-1.0)
getAlpha(): numberExample:
color.alphatoColorString
Convert to internal color string format
toColorString(): stringblack
Black color (#000000)
static black(): ColorExample:
Color.black()darkGray
Dark gray color
static darkGray(): ColorExample:
Color.darkGray()lightGray
Light gray color
static lightGray(): ColorExample:
Color.lightGray()white
White color (#FFFFFF)
static white(): ColorExample:
Color.white()gray
Gray color
static gray(): ColorExample:
Color.gray()red
Red color (iOS system red)
static red(): ColorExample:
Color.red()green
Green color (iOS system green)
static green(): ColorExample:
Color.green()blue
Blue color (iOS system blue)
static blue(): ColorExample:
Color.blue()cyan
Cyan color
static cyan(): ColorExample:
Color.cyan()yellow
Yellow color
static yellow(): ColorExample:
Color.yellow()magenta
Magenta color
static magenta(): ColorExample:
Color.magenta()orange
Orange color
static orange(): ColorExample:
Color.orange()purple
Purple color
static purple(): ColorExample:
Color.purple()brown
Brown color
static brown(): ColorExample:
Color.brown()clear
Transparent color
static clear(): ColorExample:
Color.clear()dynamic
Create a color that adapts to light/dark mode
static dynamic(lightColor, darkColor): ColorlightColor- Color for light modedarkColor- Color for dark mode
Returns: Dynamic color
Example:
Color.dynamic(Color.white(), Color.black())