color_of {photobiology}R Documentation

Color of an object

Description

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

Usage

color_of(x, ...)

## Default S3 method:
color_of(x, ...)

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

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

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

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

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

colour_of(x, ...)

color(x, ...)

Arguments

x

an R object.

...

ignored (possibly used by derived methods).

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

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.

Methods (by class)

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.

Note

When x is a list but not a waveband, if a method color_of is not available for the class of each element of the list, then color_of.default will be called.

Examples

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)



[Package photobiology version 0.9.21 Index]