String to colour.
Whether the terminal has a bright background or not.
Whether to use extended colours beyond the normal ANSI.
word, now in colour based on the hash of its contents.
import std.conv : to; { immutable coloured = "kameloso".colourByHash(brightTerminal: false, extendedColours: true); assert((coloured == "\033[38;5;227mkameloso\033[0m"), coloured); } { immutable coloured = "kameloso".colourByHash(extendedColours: true, brightTerminal: true); assert((coloured == "\033[38;5;222mkameloso\033[0m"), coloured); } { immutable coloured = "kameloso".colourByHash(brightTerminal: true); assert((coloured == "\033[38;5;222mkameloso\033[0m"), coloured); } { immutable coloured = "zorael".colourByHash(extendedColours: true); assert((coloured == "\033[35mzorael\033[0m"), coloured); } { immutable coloured = "zorael".colourByHash(extendedColours: true); assert((coloured == "\033[35mzorael\033[0m"), coloured); } { immutable coloured = "NO".colourByHash(extendedColours: true); assert((coloured == "\033[90mNO\033[0m"), coloured); }
Shorthand function to colour a passed word by the hash of it.