Color: Abstract class representing a set of colors

Description Usage Fields and Methods Author(s) References See Also Examples

Description

Package: R.colors
Class Color

Object
~~|
~~+--Color

Directly known subclasses:
BlueColor, CmykColor, CyanMagentaColor, ExcelColor, FourDimensionalColor, GrayColor, GreenColor, HclColor, HeatColor, HsvgColor, LundUniversityColor, OneDimensionalColor, RainbowColor, RedColor, RgbColor, TerrainColor, ThreeDimensionalColor, TopologyColor, TwoChannelMicroarrayColor, TwoDimensionalColor, VgaColor, WavelengthColor

public abstract static class Color
extends Object

Abstract class representing a set of colors.

Various Color classes can have various ways of representing a set of colors. Where some classes store the colors in a colorspace spanning the red, green, and blue dimensions, other classes may keep a different representation such as the wavelength of the light and so on.

By calling getColors() of a Color object the set of colors where each color is a character string with format "\#rrggbb", where rr, gg, and bb are hexadecimal values in [0x00-0xff] for the red, green and blue channel, respectively. This format is understood by all plot functions in R. By default, as.character() calls getColors(). It is expected that no subclass changes this.

Importantly, each class implementing its own getColors() should before returning the set of colors, pass them through the user-defined color filter. This is done easiest by calling colors <- viewThroughColorFilter(colors) before returning, where colors is the set of colors to be filtered. If the user has not specified a default color filter, the identical colors will be returned. This is very useful because any color can then be filtered without the user having to do it explicitly. For instance, if you want to filter all the colors to see how a "color blind" person preceives the colors, set the default color filter by calling the static method as Color$setColorFilter(DichromatColorFilter()). For more information about color filters, ColorFilter.

Usage

1

Fields and Methods

Methods:

[ -
as.character Gets a character representation of the colors.
colnames -
display Displays the current set of colors.
drawColorRamp Draw a color ramp of the colors in the current plot.
getColorFilter Gets the default color filter.
getColors Gets the set of colors in the \#rrggbb format.
getColorSpace Gets the internal representation of the colors.
image Creates an image of the current set of colors.
imageText Adds text to the last plot.
length Gets the number of colors.
palette Use these colors as the color palette in all graphics.
plotParallel Plots the column vectors in the colorspace matrix versus the index.
seq Gets the indices of all colors.
setColorFilter Sets the default color filter.
validateArgumentColorsK -
viewThroughColorFilter Filters a set of colors using the default filter.

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

[1] cyberglitz, Color Primer, webpage, 2003. http://www.cyberglitz.com/primer.htm [2] ColorMatch 5K, http://www.colormatch.dk/. First prize in the Danish 5K Awards 2002.

See Also

ColorFilter. colors.

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
39
# One-dimensional colors
ncolors <- 256
x <- seq(0,1, length=ncolors)
ch1 <- x
ch2 <- rev(x)

colors <- list(
  # One-dimensional colors
  red      = RedColor(x),
  green    = GreenColor(x),
  blue     = BlueColor(x),
  gray     = GrayColor(x),
  spectrum = WavelengthColor(seq(380,779,length=ncolors)),
  heat     = HeatColor(x),
  rainbow  = RainbowColor(x),
  topo     = TopologyColor(x),
  terrain  = TerrainColor(x),
  cm       = CyanMagentaColor(x),

  # Two-dimensional colors
  rg = TwoChannelMicroarrayColor(ch1,ch2, maxColorValue=1),
  yb = TwoChannelMicroarrayColor(ch1,ch2, hueRange=c(HsvgColor$YELLOW.HUE,HsvgColor$BLUE.HUE), maxColorValue=1),
 
  # Three-dimensional colors
  rgb  = RgbColor(x,rev(x),sample(x)),
  hcl  = HclColor(x),

  # Four-dimensional colors
  hsvg = HsvgColor(x),
  cmyk = CmykColor(x,sample(x),rev(x),x/2)
)

layout(matrix(1:16, ncol=4, byrow=TRUE))
opar <- par(mar=c(0,1,3,1)+0.5)

for(color in colors)
  display(color)

par(opar)

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