Function SRgba8.toHex

Serializes this byte value as canonical eight-digit hexadecimal RGBA.

char[9] toHex() pure nothrow @nogc @safe const;

The result is exactly nine ASCII characters: a leading # followed by two lowercase hexadecimal digits for red, green, blue, and straight alpha, in that order.

Returns

Allocation-free char[9] containing #rrggbbaa.

Example

enum packed = SRgba8(0x12, 0xAB, 0x00, 0x80);
enum hex = packed.toHex();

static assert(hex[0] == '#');
static assert(hex[1] == '1');
static assert(hex[2] == '2');
static assert(hex[3] == 'a');
static assert(hex[4] == 'b');
static assert(hex[5] == '0');
static assert(hex[6] == '0');
static assert(hex[7] == '8');
static assert(hex[8] == '0');
}