TransformColors: Color transformation

View source: R/TransformColors.R

TransformColorsR Documentation

Color transformation

Description

TransformColors modifies a vector of colors in the HSV or RGB spaces (see Details section).

Usage

TransformColors(
  v,
  delta.H = NULL,
  S.range = NULL,
  V.range = NULL,
  R.range = NULL,
  G.range = NULL,
  B.range = NULL
)

Arguments

v

a standard R color vector or a ColorParameters or GroupParameters object defined by DefineColorMap or by DefineGroupStyles.

delta.H

vector of delta hue values (default = NULL, no effect).

S.range

the targeted saturation range (default = NULL, no effect).

V.range

the targeted value range (default = NULL, no effect).

R.range

targeted range for the red component (default = NULL, no effect).

G.range

targeted range for the green component (default = NULL, no effect).

B.range

targeted range for the blue component (default = NULL, no effect).

Details

If both HSV and RGB transformation parameters are provided, the colors will be modified first in HSV space, then in RGB space. Note that TransformColors does not alter transparency values. When providing a ColorParameters or GroupParameters object as input, TransformColors returns color mapping parameters with modified threshold colors or group style parameters with modified group-associated colors.

Value

TransformColors returns either a vector of R colors or a ColorParameters or GroupParameters object depending on the type of its input argument v.

See Also

DefineColorMap, DefineGroupStyles, MakeColors

Examples


layout(matrix(1:4, 2, 2))

col.prm <- DefineColorMap(c(1,101), c("purple", "yellow"), levels = 5)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = col.prm))

# Transform to grey levels
tst <- TransformColors(col.prm, S.range = 0)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))

# Changes hues to complementary colors
tst <- TransformColors(col.prm, delta.H = 180)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))

# Maximize constrast
tst <- TransformColors(col.prm, V.range = c(0, 1))
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))

benja0x40/Barbouille documentation built on March 26, 2023, 11:38 p.m.