Struct Color

Represents RGBA color with one byte per channel

struct Color

Constructors

NameDescription
this (rgb, alpha) Make a color separately from RGB and Alpha, e.g. Color(0x7FFFD4, 0xA0).
this (red, green, blue) Make an opaque color from 3 integer components
this (red, green, blue, alpha) Make a color from 4 integer components

Fields

TypeNameDescription
ubyte
a 0 - fully transparent, 255 - fully opaque
ubyte
b
ubyte
g
ubyte
r

Properties

TypeNameDescription
bool
isFullyTransparent[get] True if the color has the alpha value meaning complete transparency
bool
isOpaque[get] True if the color has the alpha value meaning full opacity
uint
rgb[get] Pack the color into ARGB8 with full opacity
uint
rgba[get] Pack the color into ARGB8

Methods

NameDescription
addAlpha (alpha) Apply additional alpha to the color
premultiplied ()
toGray () Convert to 1-byte grayscale color
withAlpha (alpha) Returns the same color with replaced alpha channel value

Static methods

NameDescription
blend (src, dst) Blend one color over another, as in simple alpha compositing
fromHSLA (h, s, l, a) Make a color from HSL representation. h, s, and l must be in [0, 1] range
fromPacked (argb) Make a color from "hexadecimal" 32-bit 0xAARRGGBB representation
mix (c1, c2, factor) Linearly interpolate between two colors