Learn R Programming

prismatic (version 1.1.2)

clr_negate: Negates colors in RGB space

Description

Negates colors in RGB space

Usage

clr_negate(col)

Value

a colors object of same length as col.

Arguments

col

a color object or vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa" (see rgb), or a positive integer i meaning palette()[i].

Details

The negation of color is happening in the red-green-blue colorspace RGB. Meaning that if we take the specification for Orange which is rgb(255, 165, 0), then we negate by taking the oppesite number on the scale from 0 to 255, leaving us with rgb(0, 90, 255) which is a shade of blue.

Examples

Run this code
terr <- color(terrain.colors(10))

terr
clr_negate(terr)

plot(terr)
plot(clr_negate(terr))

Run the code above in your browser using DataLab