Learn R Programming

photobiology (version 0.9.16)

color_of: Color of an object

Description

A function that returns the equivalent RGB color of an object such as a spectrum or wavelength.

Usage

color_of(x, ...)

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

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

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

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

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

# S3 method for source_mspct color_of(x, ..., idx = !is.null(names(x)))

colour_of(x, ...)

color(x, ...)

Arguments

x

an R object

...

not used in current version

type

character telling whether "CMF", "CC", or "both" should be returned.

short.names

logical indicating whether to use short or long names for wavebands

idx

logical whether to add a column with the names of the elements of spct

Methods (by class)

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

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

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

  • waveband: Color at midpoint of a waveband object.

  • source_spct:

  • source_mspct:

Deprecated

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

Examples

Run this code
# NOT RUN {
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 DataLab