permuteRGB {RcppColors}R Documentation

RGB permutation

Description

Permutes the R-G-B components of a color.

Usage

permuteRGB(hexcolor, permutation = "gbr")

Arguments

hexcolor

vector or matrix or array of hexadecimal colors

permutation

a character string with three letters "r", "g" and "b"

Value

The colors after applying the permutation.

Examples

library(RcppColors)
x <- y <- seq(-1.7, 1.7, length.out = 512L)
zarray <- outer(y, x, function(x, y) {
  z <- x + 1i*y
  (1 + 1i) * log(sin((z^3 - 1)))
})
# image
img1 <- colorMap1(zarray)
# r -> b, g -> r, b -> g
img2 <- permuteRGB(img1, "brg")
# plot
opar <- par(mar = c(0,0,0,0), mfrow = c(1, 2), bg = "#002240")
plot(
  c(0, 1), c(0, 1), type = "n", asp = 1,
  xlab = NA, ylab = NA, axes = FALSE
)
rasterImage(img1, 0, 0, 1, 1, interpolate = TRUE)
plot(
  c(0, 1), c(0, 1), type = "n", asp = 1,
  xlab = NA, ylab = NA, axes = FALSE
)
rasterImage(img2, 0, 0, 1, 1, interpolate = TRUE)
par(opar)

[Package RcppColors version 0.6.0 Index]