Description Usage Arguments Fields and Methods Author(s) References Examples
Package: R.colors
Class WavelengthColor
Object
~~|
~~+--
Color
~~~~~~~|
~~~~~~~+--
OneDimensionalColor
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
WavelengthColor
Directly known subclasses:
public static class WavelengthColor
extends OneDimensionalColor
Class representing colors specified by wavelength.
Because the concept of colors is all about spectroscopy, the biology and physics of the human eye and the brain's perception of the neurological signals, there is no unique one-to-one mapping between wavelength and (R,G,B) values.
1 | WavelengthColor(wavelength=NULL, deviceGamma=0.8)
|
wavelength |
|
deviceGamma |
Gamma factor used by the |
... |
Arguments passed to the constructor of the super class. |
Methods:
getColors | Gets the set of colors in the \#rrggbb format. | |
getFrequency | Gets the frequences (in THz) of the colors. | |
getWavelength | Gets the wavelengths (in nm) of the colors. | |
range | Gets the (wavelength) range of the colors. | |
Methods inherited from OneDimensionalColor:
getColorSpace
Methods inherited from Color:
[, as.character, display, drawColorRamp, getColorFilter, getColors, getColorSpace, length, palette, plotParallel, seq, setColorFilter, viewThroughColorFilter
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clone, detach, equals, extend, finalize, gc, getEnvironment, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, registerFinalizer, save
Henrik Bengtsson (http://www.braju.com/R/)
Dan Bruton, Color Science,
http://www.physics.sfasu.edu/astro/color.html, 2002.
efg's Computer Lab, http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm, 2002.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | require(R.basic) # image270()
lambda <- seq(from=380, to=779) # in units of nm.
col <- WavelengthColor(lambda)
filters <- list(
none = ColorFilter(),
gray = GrayColorFilter()
)
if ("dichromat" %in% library()$results) {
filter <- append(filter, list(
deutan = DichromatColorFilter(type="deutan")
))
}
layout(matrix(seq(filters), ncol=1))
ofilter <- Color$getColorFilter()
for (filter in filters) {
# View the colors through the given filter
Color$setColorFilter(filter)
# Display the colors along the wavelength dimension
opar <- par(mar=c(5,2,6,2)+0.1)
image270(x=as.matrix(lambda), y=as.matrix(1), z=matrix(lambda, nrow=1), col=getColors(col), xlab=expression(paste("Top: frequency (THz), Bottom: ", lambda, "- wavelength (nm)")), ylab="", axes=FALSE)
at <- seq(from=min(lambda), to=max(lambda), by=20)
axis(side=1, at=at)
freq <- round(getFrequency(WavelengthColor(at)));
axis(side=3, at=at, labels=freq)
main <- paste(data.class(col), ": ", paste(range(col),collapse="-"), " nm", sep="");
if (data.class(filter) != "ColorFilter")
main <- paste(main, "filter through a", data.class(filter));
title(main=main);
par(opar)
}
Color$setColorFilter(ofilter)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.