applyTruecolour

Produces a terminal colour token for the colour passed, expressed in terms of red, green and blue, then writes it to the passed output range.

version(Colours)
void
applyTruecolour
(
Sink
)
(
auto ref Sink sink
,
uint r
,
uint g
,
uint b
,
const Flag!"brightTerminal" bright = No.brightTerminal
,
const Flag!"normalise" normalise = Yes.normalise
)

Parameters

sink Sink

Output range to write the final code into.

r uint

Red value.

g uint

Green value.

b uint

Blue value.

bright Flag!"brightTerminal"

Whether the terminal has a bright background or not.

normalise Flag!"normalise"

Whether or not to normalise colours so that they aren't too dark or too bright.

Examples

Appender!(char[]) sink;
int r, g, b;
numFromHex("3C507D", r, g, b);
sink.applyTruecolour(r, g, b);
sink.put("Foo");
sink.applyANSI(TerminalReset.all);
writeln(sink);  // "Foo" in #3C507D