cmix: Fast general purpose color mixer

Description Usage Arguments Value Examples

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

1
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

1
2
3
4
5
6
7
8
# 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')

memnet documentation built on May 2, 2019, 9:35 a.m.