Description Usage Arguments Value Examples
View source: R/convert_color.R
This function converts colors to an 8-digit hex format (e.g., #FFFFFFFF
). It supports
RGB values, with or without an alpha value, and with a maximum of 1 or 255. It also
supports hex values, with or without an alpha value, and without or without a leading #
.
1 | convert_color(color)
|
color |
Color. Required, and does not have a default value. This argument can be an RGB color
specified as a vector with 3 or 4 values, as in c(1, 1, 1), c(1, 1, 1, 1), c(255, 255, 255), or c(255, 255, 255, 255), or
a hex color specified as a string, as in |
This function returns a color in an 8-digit hex format with a leading #
(e.g., #FFFFFFFF
).
1 2 3 4 5 6 7 8 | convert_color(c(1, 1, 1)) # RGB, no alpha, max 1
convert_color(c(1, 1, 1, 1)) # RGB, alpha, max 1
convert_color(c(255, 255, 255)) # RGB, no alpha, max 255
convert_color(c(255, 255, 255, 255)) # RGB, alpha, max 255
convert_color("#FFFFFF") # hex, no alpha, with #
convert_color("#FFFFFFFF") # hex, alpha, with #
convert_color("FFFFFF") # hex, no alpha, without #
convert_color("FFFFFFFF") # hex, alpha, without #
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.