Description Usage Fields and Methods Author(s) See Also Examples
Package: R.colors
Class ColorFilter
Object
~~|
~~+--
ColorFilter
Directly known subclasses:
DichromatColorFilter, GrayColorFilter, MonochromeColorFilter, NegativeColorFilter, RgbColorFilter, SerialColorFilter
public static class ColorFilter
extends Object
Class representing a color filter.
This "mother" of ColorFilter classes works also as a "transparent" filter, i.e. as a filter that does not filter at all.
1 |
Methods:
getColors | Filters a set of colors. | |
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/)
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # 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)
filters <- list(
none = ColorFilter(), # or NULL
red = RgbColorFilter(c("red")),
green = RgbColorFilter(c("green")),
blue = RgbColorFilter(c("blue")),
redgreen = RgbColorFilter(c("red", "green")),
redblue = RgbColorFilter(c("red", "blue")),
greenblue = RgbColorFilter(c("green", "blue")),
gray = GrayColorFilter(),
neg = NegativeColorFilter(),
mono = MonochromeColorFilter()
)
if ("dichromat" %in% library()$results) {
filter <- append(filter, list(
deutan = DichromatColorFilter(type="deutan"),
protan = DichromatColorFilter(type="protan")
))
}
ofilter <- Color$setColorFilter(filters$gray)
for(color in colors)
display(color)
par(opar)
Color$setColorFilter(ofilter)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.