R: Equivalent Opaque Color for Transparent Color

ColToOpaque {DescTools} | R Documentation

## Equivalent Opaque Color for Transparent Color

### Description

Determine the equivalent opaque RGB color for a given partially transparent RGB color against a background of any color.

### Usage

    ColToOpaque(col, alpha = NULL, bg = NULL)

### Arguments

`col` | the color as hex value (use converters below if it's not available). `col` and `alpha` are recycled.
`alpha` | the alpha channel, if left to NULL the alpha channels of the colors are used
`bg` | the background color to be used to calculate against (default is "white")

### Details

Reducing the opacity against a white background is a good way to find usable lighter and less saturated tints of a base color. For doing so, we sometimes need to get the equivalent opaque color for the transparent color.

### Value

An named vector with the hexcodes of the opaque colors.

### Author(s)

Andri Signorell <andri@signorell.net>

### See Also

`ColToHex`, `DecToHex`, `RgbToHex`

### Examples

    cols <- c(SetAlpha("limegreen", 0.4), ColToOpaque(ColToHex("limegreen"), 0.4), "limegreen")
    barplot(c(1, 1.2, 1.3), col=cols, panel.first=abline(h=0.4, lwd=10, col="grey35"))

[Package DescTools version 0.99.34 Index]