| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/colorspace.R |
| 3 |
\name{hex} |
| 4 |
\alias{hex} |
| 5 |
\title{Convert Colors to Hexadecimal Strings} |
| 6 |
\usage{ |
| 7 |
hex(from, gamma = NULL, fixup = FALSE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{from}{The color object to be converted.} |
| 11 |
|
| 12 |
\item{gamma}{Deprecated.} |
| 13 |
|
| 14 |
\item{fixup}{Should the color be corrected to a valid RGB value before |
| 15 |
correction. The default is to convert out-of-gamut colors to the string |
| 16 |
\code{"NA"}.} |
| 17 |
} |
| 18 |
\value{ |
| 19 |
A vector of character strings. |
| 20 |
} |
| 21 |
\description{ |
| 22 |
This functions converts \code{\link{color-class}} objects into hexadecimal strings. |
| 23 |
} |
| 24 |
\details{ |
| 25 |
The color objects are first converted to sRGB color objects. They are then |
| 26 |
multiplied by 255 and rounded to obtain an integer value. These values are |
| 27 |
then converted to hexadecimal strings of the form \code{"#RRGGBB"} and |
| 28 |
suitable for use as color descriptions for R graphics. Out of gamut values |
| 29 |
are either corrected to valid RGB values by translating the the individual |
| 30 |
primary values so that they lie between 0 and 255. |
| 31 |
} |
| 32 |
\examples{ |
| 33 |
hsv <- HSV(seq(0, 360, length.out = 7)[-7], 1, 1) |
| 34 |
hsv |
| 35 |
hex(hsv) |
| 36 |
barplot(rep(1,6), col = hex(hsv)) |
| 37 |
} |
| 38 |
\seealso{ |
| 39 |
\code{\link{hex2RGB}}, \code{\link{RGB}}, \code{\link{sRGB}}, |
| 40 |
\code{\link{HSV}}, \code{\link{XYZ}}, \code{\link{LAB}}, |
| 41 |
\code{\link{polarLAB}}, \code{\link{LUV}}, \code{\link{polarLUV}}. |
| 42 |
} |
| 43 |
\author{ |
| 44 |
Ross Ihaka |
| 45 |
} |
| 46 |
\keyword{color} |