colourByHash

Shorthand function to colour a passed word by the hash of it.

  1. auto colourByHash(string word, Flags flags)
    version(Colours)
    pure @safe nothrow
    colourByHash
    (
    Flags...
    )
    (
    const string word
    ,
    const Flags flags
    )
  2. auto colourByHash(string word, CoreSettings settings)

Parameters

word string

String to colour.

flags Flags

A variadic combination of one or more std.typecons.Flag flags to configure the output.

Return Value

Type: auto

word, now in colour based on the hash of its contents.

Examples

import std.conv : to;

{
    immutable coloured = "kameloso".colourByHash(No.brightTerminal, Yes.extendedColours);
    assert((coloured == "\033[38;5;227mkameloso\033[0m"), coloured);
}
{
    immutable coloured = "kameloso".colourByHash(Yes.extendedColours, Yes.brightTerminal);
    assert((coloured == "\033[38;5;222mkameloso\033[0m"), coloured);
}
{
    immutable coloured = "kameloso".colourByHash(Yes.brightTerminal);
    assert((coloured == "\033[38;5;222mkameloso\033[0m"), coloured);
}
{
    immutable coloured = "zorael".colourByHash(Yes.extendedColours);
    assert((coloured == "\033[35mzorael\033[0m"), coloured);
}
{
    immutable coloured = "zorael".colourByHash(No.extendedColours, Yes.extendedColours);
    assert((coloured == "\033[35mzorael\033[0m"), coloured);
}
{
    immutable coloured = "NO".colourByHash(Yes.extendedColours);
    assert((coloured == "\033[90mNO\033[0m"), coloured);
}

See Also