Color

Represents an RGBA color

Constructors

this
this(int red, int green, int blue, int alpha = 255)

Construct a color with the given values. They should be in range 0 <= x <= 255, where 255 is maximum intensity and 0 is minimum intensity.

Members

Enums

ColorBlendMixinStr
enum ColorBlendMixinStr(string colu32name, string destu32name)

this mixin can be used to alphablend two uint colors; colu32name is variable that holds color to blend, destu32name is variable that holds "current" color (from surface, for example). alpha value of destu32name doesn't matter. alpha value of colu32name means: 255 for replace color, 0 for keep destu32name.

Functions

alphaBlend
Color alphaBlend(Color fore)

Perform alpha-blending of fore to this color, return new color. WARNING! This function does blending in RGB space, and RGB space is not linear!

toBW
Color toBW()

Return black-and-white color

toCssString
string toCssString()

Makes a string that matches CSS syntax for websites

toRgbaHexString
string toRgbaHexString()

returns RRGGBBAA, even if a== 255

toString
string toString()

Makes a hex string RRGGBBAA (aa only present if it is not 255)

Static functions

black
Color black()
blue
Color blue()
brown
Color brown()

Static convenience functions for common color names

fromHsl
Color fromHsl(real h, real s, real l)

from hsl

fromIntegers
Color fromIntegers(int red, int green, int blue, int alpha = 255)

Like the constructor, but this makes sure they are in range before casting. If they are out of range, it saturates: anything less than zero becomes zero and anything greater than 255 becomes 255.

fromNameString
Color fromNameString(string s)

Gets a color by name, iff the name is one of the static members listed above

fromString
Color fromString(string s)

Reads a CSS style string to get the color. Understands #rrggbb, rgba(), hsl(), and rrggbbaa

gray
Color gray()
green
Color green()
purple
Color purple()
red
Color red()
teal
Color teal()

Static convenience functions for common color names

transparent
Color transparent()
white
Color white()
yellow
Color yellow()

Static convenience functions for common color names

Unions

__anonymous
union __anonymous

The color components are available as a static array, individual bytes, and a uint inside this union.

Meta