seq_color: Interpolate (non-linearly) between two colors

View source: R/seq-color.R

seq_colorR Documentation

Interpolate (non-linearly) between two colors

Description

Interpolate (non-linearly) between two colors

Usage

seq_color(
  col1,
  col2,
  n = 100,
  type = "cubic",
  direction = "in-out",
  colorspace = "hcl"
)

Arguments

col1, col2

the two colors to interpolate between

n

Number of steps for the transition (including the endpoints)

type

Type of motion easing. Default: 'cubic'. Valid values are are 'sine', 'quad', 'cubic', 'quart', 'quint', 'exp', 'circle', 'back', 'elastic', 'linear'.

direction

When should the easing apply? Default: "in-out". Valid values are 'in', 'out', in-out'. Default: 'in-out'

colorspace

Color space in which to do the interpolation. Default: 'hcl' Can be any colorspace understood by the farver package i.e. "cmy", "cmyk", "hsl", "hsb", "hsv", "lab" (CIE L*ab), "hunterlab" (Hunter Lab), "oklab", "lch" (CIE Lch(ab) / polarLAB), "luv", "rgb" (sRGB), "xyz", "yxy" (CIE xyY), "hcl" (CIE Lch(uv) / polarLuv), or "oklch" (Polar form of oklab). Note: Not all color spaces make sense for interpolation.

Value

character vector containing a color sequence

Examples


n <- 20
cols <- seq_color('red', 'blue', n = n, direction = 'in-out', colorspace = 'hcl')
cols
grid::grid.rect(x = seq(0, 0.95, length.out = n), width = 0.1, 
                gp = grid::gpar(fill = cols, col = NA))


coolbutuseless/displease documentation built on Dec. 17, 2024, 10:07 p.m.