View source: R/manip_saturate.R
saturate | R Documentation |
Saturate or desaturate colors
saturate(x, amount = 1) desaturate(x, amount = 1)
x |
vector of colors specified as hex strings or named R colors. |
amount |
numeric amount of change in saturation. Reasonable amounts are 1 to 10. Negative amounts correspond to the opposite operation ( |
Colors are converted into HCL space where the C (chroma) component is changed. Most colors are (very slightly) affected by the conversion and the change in saturation is therefore not exactly reversible (saturating a desaturated color will not get you back to the original one); although, perceptually, the changes should be extremely subtle and only affect very bright and saturated colors.
A vector of colors specified as hex codes
Other color manipulation functions:
average()
,
blend()
,
channel()
,
darken()
,
luminance()
,
mix()
saturate("#7BBBFE") saturate(c("coral1", "#850E5D")) desaturate("darkgreen") show_col(c("hotpink", saturate("hotpink"), desaturate("hotpink")), c("lightskyblue", saturate("lightskyblue"), desaturate("lightskyblue"))) show_col(c(desaturate("salmon3", 2), desaturate("salmon3"), "salmon3", saturate("salmon3"), saturate("salmon3", 2))) # saturate() and desaturate() are opposite operations, the direction of # which is set by the sign of `amount` saturate("red", -1) desaturate("red", 1) # But they are not necessarily exactly reversible when they operate near # extreme saturation values col <- "#5EFF15" (new_col <- desaturate(saturate(col))) show_col(c(col, new_col)) # = the two greens are slightly different
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.