modify_hcl: Modify individual HCL axes

View source: R/modify.R

modify_hclR Documentation

Modify individual HCL axes

Description

This function lets you modify individual axes of a color in HCL color space.

Usage

modify_hcl(col, h, c, l)

Arguments

col

A colors object (see color()) or a vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by grDevices::colors()), a hexadecimal string (see col2rgb()), or a positive integer i meaning grDevices::palette()⁠[i]⁠.

h

Expression to modify the hue of col.

c

Expression to modify the chroma of col.

l

Expression to modify the luminance of col.

Details

The expression used in h, c, and l is evaluated in the hcl space and you have access to h, c, and l as vectors along with vectors in the calling environment.

h ranges from 0 to 360, l ranges from 0 to 100, and c while dependent on h and l will roughly be within 0 and 180, but often on a narrower range. Colors after modification will be adjusted to fit within the color space.

Value

A colors object.

Source

https://en.wikipedia.org/wiki/HCL_color_space

Examples

plot(modify_hcl("red", h = 160))
plot(modify_hcl("red", h = h + 50))

plot(modify_hcl("red", h = h + 1:100))
plot(modify_hcl("red", c = c - 1:200))
plot(modify_hcl("red", l = l + 1:50))

plot(modify_hcl(rainbow(10), l = 25))

plot(modify_hcl(rainbow(10), h + h / 2, l = 70))

EmilHvitfeldt/prismatic documentation built on Nov. 23, 2024, 10:41 a.m.