col2transparent: col2transparent

View source: R/col2transparent.R

col2transparentR Documentation

col2transparent

Description

R color to transparent conversion.

Usage

col2transparent(col, alpha.perc = 0)

Arguments

col

R color name or R color pal [mandatory]

alpha.perc

an alpha-transparency level in percent [default: 0]

Value

A character vector with elements of 9 characters, "#" followed by the red, blue, green and alpha values in hexadecimal (after rescaling to 0 ... 255).

Author(s)

Kristian K Ullrich

See Also

palette

Examples

col2transparent("green", 50)
## Demonstrate the colors 1:8 in different palettes using a custom matplot()
sinplot <- function(main=NULL) {
    x <- outer(
        seq(-pi, pi, length.out = 50),
        seq(0, pi, length.out = 9),
        function(x, y) sin(x - y)
    )
    matplot(x, type = "l", lwd = 4, lty = 1, col = 1:9, ylab = "", main=main)
}
my.palette <- c(
    "#CBC106", "#27993C", "#1C6838",
    "#8EBCB5", "#389CA7", "#4D83AB",
    "#CB7B26", "#BF565D", "#9E163C")
palette(my.palette); sinplot("my.palette")
## 25% transparent
palette(col2transparent(palette(my.palette), 25));
    sinplot("my.palette - transparent")
## 50% transparent
palette(col2transparent(palette(my.palette), 50));
    sinplot("my.palette - transparent")
## 75% transparent
palette(col2transparent(palette(my.palette), 75));
    sinplot("my.palette - transparent")

kullrich/CRBHits documentation built on March 29, 2024, 11:34 a.m.