Negate colors in RGB space
Arguments
- col
A
colors
object (seecolor()
) or a vector of any of the three kinds of R color specifications, i.e., either a color name (as listed bygrDevices::colors()
), a hexadecimal string (seecol2rgb()
), or a positive integeri
meaninggrDevices::palette()
[i]
.
Details
The negation of color is happening in the red-green-blue colorspace RGB. This means if we take the specification for orange which is rgb(255, 165, 0), then we negate by taking the opposite number on the scale from 0 to 255, leaving us with rgb(0, 90, 255), which is a shade of blue.
Examples
clr_negate("orange")
#> <colors>
#> #005AFFFF
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))