Colors
These functions are used to create and manipulate colors in Easel. In Easel, colors are stored in RGB format, but conversion functions are provided to convert to and from HSL format as well.
See Learn > Language > Types > Color to learn more about how to specify colors in Easel.
Color
Color:Accent -> color
Color:Primary -> color
Color:Secondary -> color
Color:Hover -> color
Color:Positive -> color
Color:Negative -> color
Color:Warning -> color
These Color constants can be used to help maintain a consistent color scheme across the user interface.
Color:Selected -> symbol
The special Color:Selected symbol can be used to make parts of the user interface
take on the color of the currently selected Tab.
See Tab for more information.
A
color.A -> number
Returns the alpha component of a color as a value between 0 and 1.
Returns undefined if the input is nullish.
B
color.B -> number
Returns the blue component of a color as a value between 0 and 1.
Returns undefined if the input is nullish.
BlendHue
alpha.BlendHue(from, to) -> color
Returns a color that is a blend between from and to.
The blending is done in the HSL color space.
alpha controls the amount of blending and should be a value between 0 and 1,
where 0 is from and 1 is to. Defaults to 0 if not provided.
If only one of the inputs is nullish, the other input is returned.
Darken
color.Darken(darken) -> color
Returns a new color that is darker than the input color by the given fraction.
If the fraction is negative, the color will be lightened instead.
If darken is nullish, returns the original color unchanged.
If color is nullish, returns undefined.
Fade
color.Fade(fade) -> color
Returns a new color with its opacity blended with transparent by the given fraction.
If the fraction is negative, the color will be made more opaque instead.
fade must be number between 0 and 1, where 1 represents fully transparent.
If fade is nullish, returns the original color unchanged.
If color is nullish, returns undefined.
G
color.G -> number
Returns the green component of a color as a value between 0 and 1.
Returns undefined if the input is nullish.
HSL
HSL(hue, saturation, lightness, alpha?) -> color
Returns a color comprised of the given hue, saturation, lightness and alpha components in the HSL color space.
hueis a number in between0degand360deg, where0degrepresents red. Like all angles in Easel, it is represented in radians, but you can use suffixes such asdegorrevand Easel will convert it for you at compile time.saturationis a number between0and1, where0is grayscale and1is fully saturated.lightnessis a number between0and1, where0is black and1is white.alphais a number between0and1, where0is fully transparent and1is fully opaque. Defaults to1if not provided.
Returns undefined if the input is nullish.
HSL(hue, saturation, lightness, alpha?) -> color
Returns the hue, saturation, lightness and alpha components of a color.
hueis a number between0and360deg, where0degrepresents red. Like all angles in Easel, it is represented in radians, but you can use suffixes such asdegorrevand Easel will convert it for you at compile time.saturationis a number between0and1, where0is grayscale and1is fully saturated.lightnessis a number between0and1, where0is black and1is white.alphais a number between0and1, where0is fully transparent and1is fully opaque.
Returns all undefined if the input is nullish.
Lighten
color.Lighten(lighten) -> color
Returns a new color that is lighter than the input color by the given fraction.
If the fraction is negative, the color will be darkened instead.
If lighten is nullish, returns the original color unchanged.
if color is nullish, returns undefined.
R
color.R -> number
Returns the red component of a color as a value between 0 and 1.
Returns undefined if the input is nullish.
RGB
RGB(red, green, blue, alpha?) -> color
Returns a color comprised of the given red, green, blue and alpha components.
Each component should be a number between 0 and 1.
The alpha component defaults to 1 if not provided.
Returns undefined if the input is nullish.
RGB(red, green, blue, alpha?) -> color
Returns the red, green, blue and alpha components of a color.
Each component will be a value between 0 and 1.
Returns all undefined if the input is nullish.
ShiftHue
color.ShiftHue(hueShift) -> color
Shifts the Hue of a color by the given amount and returns the result.
hueShiftshould be a number between-360and360, where0represents no change. Defaults to0if nullish.
The hue-shifting is done in the HSL color space.
If color is nullish, returns undefined.
Unfade
color.Unfade(unfade) -> color
Returns a new color with its opacity blended with fully opaque by the given fraction.
If the fraction is negative, the color will be made more transparent instead.
unfade must be Number between 0 and 1, where 1 represents fully opaque.
If unfade is nullish, returns the original color unchanged.
If color is nullish, returns undefined.
WithOpacity
color.WithOpacity(opacity) -> color
Returns the same Color except with its opacity set to the given value.
opacity must be a number between 0 and 1,
where 0 represents fully transparent and 1 represents fully opaque.
If color is nullish, returns undefined.
If opacity is nullish, returns the original color unchanged.