Create a color scale with chroma.js
new()
chroma_scale$new()
scale()
chroma_scale$scale(colors)
bezier()
chroma_scale$bezier(colors)
mode()
chroma_scale$mode(mode = c("rgb", "lab", "lrgb", "hsl", "lch"))
correctLightness()
chroma_scale$correctLightness()
colors()
chroma_scale$colors(n)
domain()
chroma_scale$domain(domain)
gamma()
chroma_scale$gamma(gamma)
padding()
chroma_scale$padding(padding)
print()
chroma_scale$print()
eval()
chroma_scale$eval(type_convert = TRUE, split_char = ",")
clone()
The objects of this class are cloneable with this method.
chroma_scale$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # Palette from white to black
cs <- chroma_scale$new()
cs$scale()
cs$colors(10)
(res <- cs$eval())
view_cols(res)
# Specify from & to colors
cs <- chroma_scale$new()
cs$scale(colors = c("yellow", "#008ae5"))
cs$colors(10)
(res <- cs$eval())
view_cols(res)
# With three colors
cs <- chroma_scale$new()
cs$scale(colors = c("yellow", "red", "black"))
cs$colors(20)
(res <- cs$eval())
view_cols(res)
# Default color space for interpolation is RGB
cs <- chroma_scale$new()
cs$scale(colors = c("yellow", "navy"))
cs$colors(20)
(res <- cs$eval())
view_cols(res)
# Change with mode
cs$mode("lab")
(res <- cs$eval())
view_cols(res)
# Correct lightness example
cs <- chroma_scale$new()
cs$scale(c("black","red","yellow","white"))
cs$colors(n = 16)
# without
(res <- cs$eval())
view_cols(res)
# with correction
cs$correctLightness()
(res <- cs$eval())
view_cols(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.