Skip to main content

Color

The Color type represents a color in 8-bit RGBA format.

Hex codes

In Easel, colors are represented as hex codes, the same as in other well-known languages like HTML and CSS. Hex codes are a way of representing colors using a combination of red, green, and blue values. The numbers are hexadecimal (base 16), instead of the usual decimal (base 10) numbers, which means they use not just the normal digits 0-9 but also the letters A-F to represent numbers 10-15.

Specifying RGB values

The most common format is the 6-digit hex code, prefixed with a # character. The first two digits representing the amount of red, second two digits representing green and third two digits representing blue.

#ff0000 // red
#00ff00 // green
#0000ff // blue
#ff8800 // orange

Specifying alpha values

If there are 8 digits, then the last two digits represent the alpha channel - how opaque the color is.

#ff000080 // red, 50% transparent

Shorthand formats

You can also use the shorthand 3-digit or 4-digit format, where each digit is duplicated to form the full 6-digit or 8-digit code respectively.

#f00 // equivalent to #ff0000
#f008 // equivalent to #ff000088

Color constants

There a certain color constants like Color:Primary that can be used. See the Colors section in the reference.