BlendColors: Mix two colors in RGB space

View source: R/z_colors.R

BlendColorsR Documentation

Mix two colors in RGB space

Description

Mix two colors in RGB space

Usage

BlendColors(x, y, gamma)

Arguments

x

vector of R colors.

y

vector of R colors.

gamma

numeric vector with values in [0 ; 1] specifying the proportion of x when mixing x and y colors.

Value

BlendColors returns a vector of R colors.

Examples


n <- 50

x <- 0:(n^2 - 1) / (n^2 - 1)
y <- rep(0:(n - 1) / (n - 1), length.out = length(x))

cm1 <- DefineColorMap(thresholds = 0:2/2, colors = c("blue", "yellow", "red"))
cm2 <- DefineColorMap(thresholds = 0:2/2, colors = grey(c(1, 0, 1)))

c1 <- MakeColors(x, cm1)
c2 <- MakeColors(x, cm2)

clr <- BlendColors(c1, c2, gamma = y)

plot(x, y, col = clr, pch = 20, cex = 2)

cm1 <- AutoColorParameters("Wry")
cm2 <- AutoColorParameters("WBW")

c1 <- MakeColors(x, cm1)
c2 <- MakeColors(x, cm2)

clr <- BlendColors(c1, c2, gamma = y)

plot(x, y, col = clr, pch = 20, cex = 2)


benja0x40/Barbouille documentation built on March 26, 2023, 11:38 p.m.