mix | R Documentation |
Mix two colors
mix(x, y, ratio = 0.5, model = "lrgb")
x, y |
colors specified as hex strings or named R colors. |
ratio |
amount of y mixed in x; |
model |
string defining the color model to compute the mix in; valid models are |
All arguments can be vectors, as long as they are of compatible length (shorter arguments will be repeated to the length of longer arguments)
A vector of colors specified as hex codes
Other color manipulation functions:
average()
,
blend()
,
channel()
,
darken()
,
luminance()
,
saturate()
mix("red", "blue") mix("red", "blue", 0.25) # Arguments can be vectors and all mixes are returned mix("red", "blue", c(0.25, 0.5, 0.75)) show_mix <- function(x, y, ...) {show_col(c(x, y, "white", mix(x, y, ...)))} show_mix("#FEF213", "#146EFD") show_mix("#FEF213", "#FA000C") show_mix("#146EFD", "#FA000C") show_mix("#146EFD", "#FA000C", ratio=c(0.25, 0.5, 0.75)) # note that results in some color models can be surprising show_mix("#FEF213", "#146EFD", model=c("hcl", "lch", "hsi", "hsl", "hsv", "lab", "rgb", "lrgb"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.