Skip to main content

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.

  • hue is a number in between 0deg and 360deg, where 0deg represents red. Like all angles in Easel, it is represented in radians, but you can use suffixes such as deg or rev and Easel will convert it for you at compile time.
  • saturation is a number between 0 and 1, where 0 is grayscale and 1 is fully saturated.
  • lightness is a number between 0 and 1, where 0 is black and 1 is white.
  • alpha is a number between 0 and 1, where 0 is fully transparent and 1 is fully opaque. Defaults to 1 if 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.

  • hue is a number between 0 and 360deg, where 0deg represents red. Like all angles in Easel, it is represented in radians, but you can use suffixes such as deg or rev and Easel will convert it for you at compile time.
  • saturation is a number between 0 and 1, where 0 is grayscale and 1 is fully saturated.
  • lightness is a number between 0 and 1, where 0 is black and 1 is white.
  • alpha is a number between 0 and 1, where 0 is fully transparent and 1 is 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.

  • hueShift should be a number between -360 and 360, where 0 represents no change. Defaults to 0 if 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.