String to hash and base colour on.
Whether the terminal has a bright background or not.
Whether to use extended colours or not.
A uint that can be used in an ANSI foreground colour sequence.
immutable nickColour = "kameloso".getColourByHash(brightTerminal: false, extendedColours: true);
import std.conv : to; { enum word = "kameloso"; immutable hash = getColourByHashImpl(word, brightTerminal: false, extendedColours: true); assert((hash == 227), hash.to!string); } { enum word = "kameloso^"; immutable hash = getColourByHashImpl(word, brightTerminal: false, extendedColours: true); assert((hash == 46), hash.to!string); } { enum word = "zorael"; immutable hash = getColourByHashImpl(word, brightTerminal: true, extendedColours: true); assert((hash == 35), hash.to!string); } { enum word = "NO"; immutable hash = getColourByHashImpl(word, brightTerminal: true, extendedColours: true); assert((hash == 90), hash.to!string); }
Hashes the passed string and picks an ANSI colour for it by modulo. Implementation function.
Picks any colour, taking care not to pick black or white based on the passed brightTerminal bool. If the extendedColours bool is passed, it will pick from the extended colour range instead of the basic one.