Learn R Programming

memnet (version 0.1.0)

cmix: Fast general purpose color mixer

Description

Mixes two colors or matching vectors of colors according to some relative weight and exports the result either in rgb or hex format.

Usage

cmix(col_1, col_2, weight, format = "hex")

Arguments

col_1, col_2

character vector of length one or of matching length containing colors either as a color name (see colors), rgb format (see rgb), or hex format.

weight

numeric between 0 and 1 specifying the relative mixing weight for color one. E.g., weight = .8 means that final color is composed of 80 percent col_2 and 20 percent col_1.

format

character string specifying the output format. Either "hex" or "rgb".

Value

A vector of length max(length(col_1), length(col_2)) containing the mixed colors in the specified format.

Examples

Run this code
# NOT RUN {
# mix blue and red with more weight on blue
cmix('blue', 'red', .2)

# mix blue and red with more weight on red
cmix('blue', 'red', .8)

# mix blue and red and return as rgb
cmix('blue', 'red', .8, format = 'rgb')

# }

Run the code above in your browser using DataLab