Struct Color

D struct that wraps SDL_Color containing 4 bytes for storing color values of 3 color channels and 1 alpha channel.

struct Color ;

dsdl2.Color stores unsigned byte-sized (0-255) red, green, blue color, and alpha channel values. In total there are 16,777,216 possible color values. Combined with the alpha (transparency) channel, there are 4,294,967,296 combinations.

Examples

auto red = dsdl2.Color(255, 0, 0);
auto translucentRed = dsdl2.Color(255, 0, 0, 128);

Constructors

NameDescription
this (sdlColor) Constructs a dsdl2.Color from a vanilla SDL_Color from bindbc-sdl
this (r, g, b, a) Constructs a dsdl2.Color by feeding in red, green, blue, and optionally alpha values
this (rgb) Constructs a dsdl2.Color by feeding in an array of red, green, and blue, with alpha being 255
this (rgba) Constructs a dsdl2.Color by feeding in an array of red, green, blue, and alpha

Fields

NameTypeDescription
sdlColor sdl.pixels.SDL_ColorInternal SDL_Color struct

Properties

NameTypeDescription
a[get] inout(ubyte)Proxy to the alpha transparency value of the dsdl2.Color
array[get] inout(ubyte[4])Static array proxy of the dsdl2.Color
b[get] inout(ubyte)Proxy to the blue color value of the dsdl2.Color
g[get] inout(ubyte)Proxy to the green color value of the dsdl2.Color
r[get] inout(ubyte)Proxy to the red color value of the dsdl2.Color

Methods

NameDescription
toString () Formats the dsdl2.Color into its construction representation: "dsdl2.Color(<r>, <g>, <b>, <a>)"