trgb: Interpolate Colors

Description Usage Arguments Value Author(s) See Also Examples

View source: R/animatoR-functions-knitr.R

Description

This function interpolates the color between start and end color.

Usage

1
2
trgb(x0, x1 = x0, t, when = c(0, 1), p = 1, alpha0 = 1, alpha1 = 1,
  ...)

Arguments

x0

vector specifying start colors or factor. Colors can be specified as numbers or character strings, see colors. Factors are also acceptable in which case the input will be transformed into level numbers.

x1

vector specifying end colors or factor. Colors can be specified as numbers or character strings, see colors. Factors are also acceptable in which case the input will be transformed into level numbers.

t

numeric, homotopy parameter, limited between 0 and 1. This parameter can be considered as fraction of animation duration time.

when

numeric vector. This parameter controls the times of: entrance, exit, start of movement and, end of movement.

p

numeric, homotopy power parameter. Defaults to 1.

alpha0, alpha1

numeric, transparency value rgb.

...

additional arguments passed to rgb.

Value

A character vector with elements of 7 or 9 characters, "#" followed by the red, blue, green and optionally alpha values in hexadecimal (after rescaling to 0 ... 255). The optional alpha values range from 0 (fully transparent) to 255 (opaque).

Author(s)

Andrej Blejec andrej.blejec@nib.si

See Also

rgb for setting colors and colors for color names.

See link{makeTransparent} to add transparency to the colors.

Examples

1
2
3
4
5
6
if(interactive()){
animator('
newplot()
points(5,5,col=trgb("red","blue",t,alpha1=1),pch=16,cex=tcex(80,160,t))',
life=1)
}

ablejec/animatoR documentation built on Feb. 21, 2020, 10:09 p.m.