Color
Stores color data including opacity.
A color can be created using a hex value, e.g. #FF0000 and optionally an alpha or it can be created using the provided system colors.
Properties
Section titled “Properties”Alpha of the color.
alpha: numberRead-only.
Amount of blue in the color.
blue: numberRead-only.
Amount of green in the color.
green: numberRead-only.
HEX representation.
hex: stringRead-only.
Amount of red in the color.
red: numberRead-only.
Methods
Section titled “Methods”
new Color(hex, alpha)
Section titled “new Color(hex, alpha)”Constructs a color.
new Color(hex: string, alpha: number)Constructs a new color with a hex value and optionally an alpha value. The hex value may specify the alpha value but this will be ignored if the alpha value parameter is provided. Examples of valid hex values: #ff0000, #00ff0080 #00f and #ff. The hashtag is optional.
Parameters
Section titled “Parameters”hex string
Hex value.
alpha number
Alpha value.
black()
Section titled “black()”Constructs a black color.
static black(): ColorReturn value
Section titled “Return value”Color
A black color.
blue()
Section titled “blue()”Constructs a blue color.
static blue(): ColorReturn value
Section titled “Return value”Color
A blue color.
brown()
Section titled “brown()”Constructs a brown color.
static brown(): ColorReturn value
Section titled “Return value”Color
A brown color.
clear()
Section titled “clear()”Constructs a transparent color.
static clear(): ColorReturn value
Section titled “Return value”Color
A transparent color.
cyan()
Section titled “cyan()”Constructs a cyan color.
static cyan(): ColorReturn value
Section titled “Return value”Color
A cyan color.
darkGray()
Section titled “darkGray()”Constructs a dark gray color.
static darkGray(): ColorReturn value
Section titled “Return value”Color
A dark gray color.
dynamic(lightColor, darkColor)
Section titled “dynamic(lightColor, darkColor)”Creates a dynamic color.
static dynamic(lightColor: Color, darkColor: Color): ColorThe dynamic color will use either its light or dark variant depending the appearance of the system.
DrawContext resolves the color when drawing in the app. The resulting image keeps that color when the appearance changes.
Parameters
Section titled “Parameters”lightColor Color
Color used in light appearance.
darkColor Color
Color used in dark appearance.
Return value
Section titled “Return value”Color
Dynamic color.
gray()
Section titled “gray()”Constructs a gray color.
static gray(): ColorReturn value
Section titled “Return value”Color
A gray color.
green()
Section titled “green()”Constructs a green color.
static green(): ColorReturn value
Section titled “Return value”Color
A green color.
lightGray()
Section titled “lightGray()”Constructs a light gray color.
static lightGray(): ColorReturn value
Section titled “Return value”Color
A light gray color.
magenta()
Section titled “magenta()”Constructs a magenta color.
static magenta(): ColorReturn value
Section titled “Return value”Color
A magenta color.
orange()
Section titled “orange()”Constructs a orange color.
static orange(): ColorReturn value
Section titled “Return value”Color
A orange color.
purple()
Section titled “purple()”Constructs a purple color.
static purple(): ColorReturn value
Section titled “Return value”Color
A purple color.
Constructs a red color.
static red(): ColorReturn value
Section titled “Return value”Color
A red color.
white()
Section titled “white()”Constructs a white color.
static white(): ColorReturn value
Section titled “Return value”Color
A white color.
yellow()
Section titled “yellow()”Constructs a yellow color.
static yellow(): ColorReturn value
Section titled “Return value”Color
A yellow color.