Skip to contents

Negates colors in RGB space

Usage

clr_negate(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].

Value

a colors object of same length as col.

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

terr <- color(terrain.colors(10))

terr
#> <colors>
#> #00A600FF #2DB600FF #63C600FF #A0D600FF #E6E600FF #E8C32EFF #EBB25EFF #EDB48EFF #F0C9C0FF #F2F2F2FF 
clr_negate(terr)
#> <colors>
#> #FF59FFFF #D249FFFF #9C39FFFF #5F29FFFF #1919FFFF #173CD1FF #144DA1FF #124B71FF #0F363FFF #0D0D0DFF 

plot(terr)

plot(clr_negate(terr))