photobiology (version 0.11.1)

color_of: Color of an object

Description

Equivalent RGB color of an object such as a spectrum, wavelength or waveband.

Usage

color_of(x, ...)

# S3 method for default color_of(x, ...)

# S3 method for numeric color_of(x, type = "CMF", chroma.type = type, ...)

# S3 method for list color_of(x, short.names = TRUE, type = "CMF", chroma.type = type, ...)

# S3 method for waveband color_of(x, short.names = TRUE, type = "CMF", chroma.type = type, ...)

# S3 method for source_spct color_of(x, type = "CMF", chroma.type = type, ...)

# S3 method for source_mspct color_of(x, ..., idx = "spct.idx")

colour_of(x, ...)

color(x, ...)

fast_color_of_wl(x, type = "CMF", ...)

fast_color_of_wb(x, type = "CMF", ...)

Value

A color definition in hexadecimal format as a character string of 7 characters, "#" followed by the red, blue, and green values in hexadecimal (scaled to 0 ... 255). In the case of the specialization for

list, a list of such definitions is returned. In the case of a collection of spectra, a data.frame with one column with such definitions and by default an additional column with names of the spectra as index. In case of missing input the returned value is NA.

Arguments

x

an R object.

...

ignored (possibly used by derived methods).

type, chroma.type

character telling whether "CMF", "CC", or "both" should be returned for human vision, or an object of class chroma_spct for any other trichromic visual system.

short.names

logical indicating whether to use short or long names for wavebands

idx

character Name of the column with the names of the members of the collection of spectra.

Methods (by class)

  • color_of(default): Default method (returns always "black").

  • color_of(numeric): Method that returns Color definitions corresponding to numeric values representing a wavelengths in nm.

  • color_of(list): Method that returns Color of elements in a list.

  • color_of(waveband): Color at midpoint of a waveband object.

  • color_of(source_spct):

  • color_of(source_mspct):

Deprecated

Use of color() is deprecated as this wrapper function may be removed in future versions of the package because of name clashes. Use color_of() instead.

Examples

Run this code
wavelengths <- c(300, 420, 500, 600, NA) # nanometres
color_of(wavelengths)
color_of(waveband(c(300,400)))
color_of(list(blue = waveband(c(400,480)), red = waveband(c(600,700))))
color_of(numeric())
color_of(NA_real_)

color_of(sun.spct)

Run the code above in your browser using DataCamp Workspace