Returns lightened or darkened colors, vectorised over percentage. ramp is valid for any couple of colors. Functions darken() and lighten() call ramp to respectively darken and lighten a given color.

ramp(fromcol, tocol, percentage = 50, as_rgb = FALSE)

darken(col, percentage = 50, as_rgb = FALSE)

lighten(col, percentage = 50, as_rgb = FALSE)

Arguments

fromcol

starting color, i.e. if percentage = 0, it is the color returned.

tocol

color to nuance fromcol, i.e. if percentage = 100, it is the color returned.

percentage

percentage determining the percentage of tocol used to nuance fromcol. Note that darken and lighten support negative percentage.

as_rgb

a logical. Should the color(s) returned as a matrix object?

col

the color to be darkened or lightened.

Functions

  • ramp: Returns a shaded color.

  • darken: Darken a color.

  • lighten: Lighten a color.

See also

Examples

showPalette(ramp("blue", "red", 10*3:7)) darken('red', 50)
#> [1] "#7F0000"
more_reds <- lighten('red', seq(10,90,9)) showPalette(more_reds)