Learn R Programming

shades (version 1.4.0)

shade: The shade class

Description

Objects of class "shade" are simply standard R character vectors representing one or more 8-bit (s)RGB colours in CSS-like hex format, but with extra attributes giving the current colour space and coordinates.

Usage

shade(x, ...)

# S3 method for shade shade(x, ...)

# S3 method for color shade(x, ...)

# S3 method for matrix shade(x, space = "sRGB", alpha = NULL, ...)

# S3 method for character shade(x, ...)

# S3 method for default shade(x, ...)

# S3 method for shade print(x, ...)

# S3 method for shade [(x, i)

# S3 method for shade [(x, i) <- value

# S3 method for shade c(...)

# S3 method for shade rep(x, ...)

# S3 method for shade rev(x)

# S3 method for shade ==(x, y)

# S3 method for shade !=(x, y)

# S3 method for equal.shade all(target, current, hexonly = FALSE, ...)

Arguments

x, y

R objects, or "shade" objects for methods.

...

Additional parameters to methods. For c, any number of colours in any acceptable form.

space

For a matrix, the space in which coordinates are being provided.

alpha

For a matrix, an associated vector of opacity values between 0 and 1, if required.

i

An index vector.

value

A vector of replacement colours.

target, current

Shade vectors to compare.

hexonly

If TRUE, compare only on the basis of the hex strings. Otherwise test for equal coordinates.

Value

A character vector of class "shade", with additional attributes as follows.

space

A string naming a color space.

coords

A matrix giving colour coordinates in the relevant space, one colour per row.

Details

Comparison between "shade" objects x and y is achieved by converting y (the second argument) into the colour space of x and then comparing coordinates, after any clipping.

Examples

Run this code
# NOT RUN {
s <- shade(c("red", "green", "blue"))
s[1]
s[1] <- "pink"
# }

Run the code above in your browser using DataLab