Quantize a character vector of hex colours into a lofi (reduced bit) representation, and output this as a vector of integers.

hex_colour_to_lofi(cols, rgb_bits)

lofi_to_hex_colour(lofi, rgb_bits)

Arguments

cols

character vector of hex colours e.g. c('#ffaa70', '#00a0e2')

rgb_bits

3-element vector with number of bits to represent each of the 3 colour channels. Each element must be in the range [1,8]

lofi

vector of integers. Each integer contains a low-bit representation of a colour.

Value

Return integer vector. Each integer represents a colour.

Details

A hex colour (e.g. '#ffaa70') is a character representation of a 24-bit colour i.e. 3 colour channels, each represented by an 8 bit number.

lofi colour is a representation of a colour using a low number of bits for each colour channel, and then packed as an integer.

See wikipedia articles: