color_conv: Convert colors

Description Usage Arguments Details Value Examples

View source: R/colors.R

Description

Convert from common color inputs to specified output type, adding alpha transparency.

Usage

1
2
3
4
5
6
color_conv(
  color,
  alpha = 1,
  from = c("guess", "col", "hex", "hexa", "hex3", "rgb", "rgba"),
  to = c("hexa", "hex", "rgba", "rgb", "hsv")
)

Arguments

color

A color in one of the input formats (see Details)

alpha

Alpha transparency (values <=1 converted to 0-255); ignored if color has alpha already

from, to

Input and output color spaces, see Details below.

Details

color: one of the R colours listed in ccolors(), e.g., "red" hex: hexadecimal string, e.g., "#FF0000" hexa: hexadecimal string with alpha, e.g., "#FF0000FF" hex3: abbreviated hexadecimal string, e.g., "#F00" rgb: vector of red, green and blue values 0-255, e.g., c(255, 0, 0) rgb: vector of red, green, blue and alpha values 0-255, e.g., c(255, 0, 0, 255) hsv: vector of hue, saturation and value values (0-1), e.g., c(h=0, s = 1, v = 1)

Value

color in to format

Examples

1
2
3
4
5
6
7
color_conv("red")
color_conv("#FF0000")
color_conv("#FF0000FF")
color_conv(c(255,0,0))
color_conv(c(255,0,0,255))

color_conv("dodgerblue", 0.5, to = "rgba")

facelab/webmorph documentation built on April 11, 2021, 6:34 a.m.