Skip to contents

Mix or blend multiple colors between two colors

Usage

mix.cols.btw(colors, max = 20, alpha = 1, preview = FALSE)

Arguments

colors

the vector of two colors

max

maximum number of colors to blend between

alpha

alpha for the new color blends

preview

LOGICAL. preview all color generated

Value

color hex for all generated colors

Examples

# simply mix/blend two colors
mix.cols.btw(c("red","brown"))
#>  [1] "red"       "#FF0101FF" "#FE0101FF" "#FD0202FF" "#FA0303FF" "#F70505FF"
#>  [7] "#F40606FF" "#EF0909FF" "#EC0A0AFF" "#E90B0BFF" "#DE1010FF" "#DB1212FF"
#> [13] "#D81313FF" "#D21515FF" "#C71B1BFF" "#BC2020FF" "#B72323FF" "#B42424FF"
#> [19] "#B12525FF" "brown"    

# simply mix/blend two colors, maximum number of colors at the end
mix.cols.btw(c("red","brown"), max = 8)
#> [1] "red"       "#FA0303FF" "#F40606FF" "#E90B0BFF" "#DE1010FF" "#D21515FF"
#> [7] "#BC2020FF" "brown"    

# simply mix/blend two colors with alpha=0.2 (opacity=0.2)
mix.cols.btw(c("yellow","green"),alpha = 0.2)
#>  [1] "yellow"    "#FEFF0033" "#FCFF0033" "#F8FF0033" "#F0FF0033" "#E8FF0033"
#>  [7] "#E0FF0033" "#D0FF0033" "#C8FF0033" "#C0FF0033" "#A0FF0033" "#98FF0033"
#> [13] "#90FF0033" "#80FF0033" "#60FF0033" "#40FF0033" "#30FF0033" "#28FF0033"
#> [19] "#20FF0033" "green"    

# also preview after mixing the two colors
mix.cols.btw(c("red","green"), preview = TRUE)

#>  [1] "red"       "#FE0200FF" "#FC0400FF" "#F80800FF" "#F01000FF" "#E81800FF"
#>  [7] "#E02000FF" "#D03000FF" "#C83800FF" "#C04000FF" "#A06000FF" "#986800FF"
#> [13] "#907000FF" "#808000FF" "#60A000FF" "#40C000FF" "#30D000FF" "#28D800FF"
#> [19] "#20E000FF" "green"    
mix.cols.btw(c("blue","violet"),alpha = 0.2, preview = TRUE)

#>  [1] "blue"      "#0202FF33" "#0403FF33" "#0805FF33" "#0F09FE33" "#170DFE33"
#>  [7] "#1E11FD33" "#2D19FC33" "#351DFC33" "#3C21FB33" "#5A31F933" "#6235F933"
#> [13] "#6939F833" "#7741F733" "#9552F533" "#B362F333" "#C26AF233" "#CA6EF233"
#> [19] "#D172F133" "violet"   

mix.cols.btw(c("red","purple","yellow","gray"), preview = TRUE)

#>  [1] "red"       "#FD0108FF" "#FA020FFF" "#F4041EFF" "#E8083CFF" "#DC0C5AFF"
#>  [7] "#D01078FF" "#B818B4FF" "#AC1CD2FF" "purple"    "#D09078FF" "#DCAC5AFF"
#> [13] "#E8C83CFF" "yellow"    "#EFEF30FF" "#DFDF5FFF" "#D7D777FF" "#D3D383FF"
#> [19] "#CFCF8FFF" "gray"     

mix.cols.btw(c("red","purple","yellow","gray"),alpha = 0.2, preview = TRUE)

#>  [1] "red"       "#FD010833" "#FA020F33" "#F4041E33" "#E8083C33" "#DC0C5A33"
#>  [7] "#D0107833" "#B818B433" "#AC1CD233" "purple"    "#D0907833" "#DCAC5A33"
#> [13] "#E8C83C33" "yellow"    "#EFEF3033" "#DFDF5F33" "#D7D77733" "#D3D38333"
#> [19] "#CFCF8F33" "gray"