shade: The shade class

Description Usage Arguments Details Value Note Author(s) Examples

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

 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
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, ...)

## 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 '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.

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.

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.

Note

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.

Author(s)

Jon Clayden <code@clayden.org>

Examples

1
2
3
s <- shade(c("red", "green", "blue"))
s[1]
s[1] <- "pink"

shades documentation built on Aug. 2, 2019, 5:05 p.m.