Class Palette

D class that wraps SDL_Palette storing multiple dsdl2.Color as a palette to use along with indexed dsdl2.PixelFormat instances

class Palette ;

Constructors

NameDescription
this (sdlPalette, isOwner, userRef) Constructs a dsdl2.Palette from a vanilla SDL_Palette* from bindbc-sdl
this (ncolors) Constructs a dsdl2.Palette and allocate memory for a set amount of dsdl2.Colors
this (colors) Constructs a dsdl2.Palette from an array of dsdl2.Colors

Fields

NameTypeDescription
sdlPalette sdl.pixels.SDL_Palette*Internal SDL_Palette pointer

Properties

NameTypeDescription
colors[get] inout(Color[])Proxy to the dsdl2.Color array of the dsdl2.Palette
length[get] ulongGets the length of dsdl2.Colors allocated in the dsdl2.Palette

Methods

NameDescription
opDollar () Dollar sign overload
opEquals (rhs) Equality operator overload
opIndex (i) Indexing operation overload
toHash () Gets the hash of the dsdl2.Palette
toString () Formats the dsdl2.Palette into its construction representation: "dsdl2.Palette([<list of dsdl2.Color>])"

Example

auto myPalette = new dsdl2.Palette([dsdl2.Color(1, 2, 3), dsdl2.Color(3, 2, 1)]);
assert(myPalette.length == 2);
assert(myPalette[0] == dsdl2.Color(1, 2, 3));