| shade | R Documentation |
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.
Opacity values are also supported.
shade(x, ...)
## S3 method for class 'shade'
shade(x, ...)
## S3 method for class 'color'
shade(x, ...)
## S3 method for class 'matrix'
shade(x, space = "sRGB", alpha = NULL, ...)
## S3 method for class 'character'
shade(x, ...)
## Default S3 method:
shade(x, ...)
shades(...)
## S3 method for class 'shade'
print(x, ...)
## S3 method for class 'shade'
x[i]
## S3 replacement method for class 'shade'
x[i] <- value
## S3 method for class 'shade'
c(...)
## S3 method for class 'shade'
rep(x, ...)
## S3 method for class 'shade'
rev(x)
## S3 method for class 'shade'
x == y
## S3 method for class 'shade'
x != y
## S3 method for class 'shade'
all.equal(target, current, hexonly = FALSE, ...)
x, y |
R objects, or |
... |
For |
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 |
The shade() function creates a colour vector from a single main argument
plus method-specific arguments where appropriate. The shades() function
provides an alternative interface that converts each of its arguments to
shades, with direct inline naming, and then concatenates them.
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.
A character vector of class "shade", with additional attributes
as follows.
space |
A string naming a colour space. |
coords |
A matrix giving colour coordinates in the relevant space, one colour per row. |
alpha |
A numeric vector of alpha (opacity) values between 0 and 1, one value per element of the vector. If not present then full opacity is assumed for every element. |
names |
A character vector of element names, in the usual R convention. If not present then the object is unnamed. |
When concatenating, shades that are all from the same space will remain in that space, but shades from different spaces will be warped to "XYZ" space.
Jon Clayden code@clayden.org
s <- shade(c("red", "green", "blue"))
s[1]
s[1] <- "pink"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.