update_alpha {gridpattern}R Documentation

Update colour and/or pattern transparency

Description

update_alpha() modifies the transparency of colours and/or patterns.

Usage

update_alpha(fill, alpha)

Arguments

fill

A fill colour given as a character or integer vector, or as a (list of) ⁠<GridPattern>⁠ object(s) and/or colour(s).

alpha

A transparency value between 0 (transparent) and 1 (opaque), parallel to fill.

Details

Value

A character vector of colours or list of ⁠<GridPattern>⁠ objects.

Usage in other packages

To avoid taking a dependency on gridpattern you may copy the source of update_alpha() into your own package under the permissive MIT license. Either use usethis::use_standalone("trevorld/gridpattern", "standalone-update_alpha.R") or copy the file update_alpha.R into your R directory and add grDevices, grid, and rlang to the Imports of your DESCRIPTION file.

Examples

# Typical color input
update_alpha("red", 0.5)

# Pattern input
if (getRversion() >= "4.2" && requireNamespace("grid", quietly = TRUE)) {
  update_alpha(list(grid::linearGradient()), 0.5)
}

[Package gridpattern version 1.2.2 Index]