alter.cols: Modify vectors of colors

View source: R/plot_Utilities.R

alter.colsR Documentation

Modify vectors of colors

Description

This function alters a vector of colors by modifying their transparency and/or mixing them with other colors.

Usage

alter.cols(x, alpha = NA, mix = NA, wgt = 0.5)

Arguments

x

A vector of colors specified either by name, hexadecimal code, or numbers (corresponding to colors defined in palette()). RGB values can be coerced to hexadecimal codes via the rgb().

alpha

A numeric vector of alpha (transparency) values, with 0 corresponding to complete transparency and 1 to complete opaqueness. Use NA to not modify transparency of colors in x.

mix

Another vector of colors to mix with the colors in x. Use NA to prevent any mixing.

wgt

A numeric vector of weights to control how colors in mix are combined with colors in x, with 0 corresponding to no mixing and 1 to complete replacement.

Value

a character vector of color values in hexadecimal code.

Examples

colors<-c('red','green','blue')
alter.cols(colors,alpha=c(0,1,0.5),mix=c('white','black','gray'),wgt=c(0,0.5,1))
#recycling behavior--recycled to maximum possible length
alter.cols(colors,alpha=0.2,mod.val=c('black','white'),wgt=c(0.1,0.2,0.8,0.9))


bstaggmartin/contSimmap documentation built on Jan. 26, 2024, 2:09 p.m.