colourtools

0th

Percentile

Convert and Compare Colours in Different Formats

These functions convert between different formats for specifying a colour in R, and determine whether colours are equivalent.

Keywords
color
Usage
col2hex(x)
rgb2hex(v)
paletteindex(x)
samecolour(x,y)
Arguments
x,y
Any valid specification for a colour or sequence of colours accepted by col2rgb.
v
A numeric vector of length 3, giving the RGB values (0 to 255) of a single colour, or a 3-column matrix giving the RGB values of several colours.
Details

col2hex converts colours specified in any format into their hexadecimal character codes.

rgb2hex converts RGB colour values into their hexadecimal character codes.

paletteindex checks whether the colour or colours specified by x are available in the default palette returned by palette(). If so, it returns the index or indices of the colours in the palette. If not, it returns NA.

samecolour decides whether two colours x and y are equivalent.

Value

  • For col2hex and rgb2hex, a character vector containing hexadecimal colour codes.

    For paletteindex, an integer vector, possibly containing NA values.

    For samecolour, a logical value or logical vector.

Warning

paletteindex("green") returns NA because the green colour in the default palette is called "green3".

See Also

col2rgb, palette

Aliases
  • paletteindex
  • rgb2hex
  • col2hex
  • paletteindex
  • samecolour
Examples
samecolour("grey", "gray")
  paletteindex("grey")
Documentation reproduced from package spatstat, version 1.23-2, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.