This is a version of
grDevices::col2rgb() that returns the colour values in
the standard form expected by farver (matrix with a row per colour). As with
encode_colour() it can do colour conversion on the fly, meaning that you can
decode a hex string directly into any of the supported colour spaces.
decode_colour(colour, alpha = FALSE, to = "rgb", white = "D65", na_value = NA)
A character vector of hex-encoded values or a valid colour name
as given in
The output colour space. Allowed values are:
The white reference of the output colour space. Will only have
an effect for relative colour spaces such as Lab and luv. Any value accepted
A valid colour string or
A numeric matrix with a row for each element in
colour and either
3, 4, or 5 columns depending on the value of
Inf are treated as invalid input and will result
NA values for the colour. If a given colourspace has finite bounds in
some of their channels, the input will be capped before conversion, and the
output will be capped before returning, so that both input and output colours
are valid colours in their respective space. This means that converting back
and forth between two colourspaces may result in a change in the colour if
the gamut of one of the spaces is less than the other.
Other encoding and decoding functions:
# basic use decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4')) # Return alpha as well (no alpha value is interpreted as 1) decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4'), alpha = TRUE) # Decode directly into specific colour space decode_colour(c('#43e1f6', 'steelblue', '#67ce9fe4'), to = 'lch')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.