cmyk: CMYK color specification

View source: R/parse_cmyk.R

cmykR Documentation

CMYK color specification

Description

Create a vector of colors from cyan, magenta, yellow, and black

Usage

cmyk(c = 0, m = 0.6, y = 0.6, k = 0.4)

Arguments

c, m, y, k

color components, numeric vectors with values in [0, 1].

Details

The first argument can also be a data.frame or a matrix. In that case, its columns are considered as the color components, taken in order, and the other color components arguments are ignored.

When separate arguments are used for the color components and are vectors, values in shorter arguments are recycled to match the length of the longest argument. If the lengths are not compatible, an error is output.

In R (and in chroma) colors are represented internally in the sRGB color space. CMYK is the color model used by printers, which use cyan, magenta, yellow and black ink. The CMYK model and its associated color spaces cannot reproduce all sRGB colors, seen on screens; bright and flashy colors in particular. On the other hand, some CMYK colors are not representable in sRGB; in those cases, they will be converted to the nearest sRGB color. It is therefore possible for two different cmyk specifications to yield the same sRGB hex code.

Value

A vector of colors specified as hex codes

See Also

parse_color for the general function to parse colors in various specifications (which this function calls internally) and convert_color to convert parsed colors to another model.

Other color specifications: css(), hcl(), hex(), hsi(), hsl(), hsv(), lab(), parse_color(), rgb(), ryb(), temperature(), wavelength()

Examples

cmyk()
cmyk(0, 0, 0, 0.1)
cmyk(data.frame(c(1, 0.5), c(1, 1), c(1, 1), c(0.5, 0.5)))
cmyk(matrix(c(1, 0.5, 1, 1, 1, 1, 0.5, 0.5), ncol=4))
cmyk(c=0.5, m=1, y=1, k=c(0.25, 0.5, 0.75))

# Color ramp
show_col(cmyk(k=seq(0, 1, length.out=10)))

jiho/chroma documentation built on Nov. 26, 2022, 2:39 a.m.