cns: A Color Naming System

Description Usage Arguments Details Value Note for SAS users References Examples

View source: R/cns.R

Description

Convert color names to RGB hex codes.

Usage

1
  cns(descriptions, ...)

Arguments

descriptions, ...

color names.

Details

Color names may be provided with the following format:

"<Lightness> <Saturation> <Hue> <Hue2>"

where words are seperated by spaces, dashes, or underscores.

<Lightness> may take the values:

white, very light, light, medium, dark, very dark, black

<Saturation> may take the following values:

gray, grayish, moderate, strong, vivid.

<Hue> may take the values:

red, orange, brown, yellow, green, blue, purple

If two hues are specified, they are blended 1:1, unless the 'ish' form is used, which specifies a 3:1 blend.

If the hue is not built-in, the hue of the corresponding system color is used.

Value

A character vector of RGB hex codes.

Note for SAS users

This is parameterized using the 1986 paper, which probably has different values than the SAS 9 implementation. While the color names should be compatible, the shades may be slightly different, particularly for browns.

References

Berk, T., Brownston, L., & Kaufman, A. (1982). A New Color-Naming System for Graphics Languages. IEEE Computer Graphics and Applications, 2(03), 37-44.

Kaufman, A. (1986). Computer artist's color naming system. The Visual Computer, 2(4), 255-260.

Examples

1
2
3
4
5
6
7
8
  barplot(1:3, col=cns('light red', 'red', 'dark purplish red'))

  # Unmatched hues are looked up in the system colors but can still be modified
  barplot(1:3, col=cns(
    'dark dodgerblue',
    'medium royalblue4',
    'grayish green midnightblue')
  )

cns documentation built on July 19, 2021, 9:07 a.m.

Related to cns in cns...