WavelengthColor: Class representing colors specified by wavelength

Description Usage Arguments Fields and Methods Author(s) References Examples

Description

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.

Usage

1
WavelengthColor(wavelength=NULL, deviceGamma=0.8)

Arguments

wavelength

vector of wavelengths (in units of nm). Note that there is no upper limit (maxColorValue) of possible wavelength but above a certain limit they will not be visible (shown).

deviceGamma

Gamma factor used by the *getColors() method.

...

Arguments passed to the constructor of the super class.

Fields and Methods

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

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

References

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.

Examples

 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)

HenrikBengtsson/R.colors documentation built on May 6, 2019, 11:53 p.m.