colorspace (version 0.9)

hex: Convert Colors To Hexadecimal Strings

Description

This functions converts ``color'' objects into hexadecimal strings.

Usage

hex(from, gamma = 2.2, fixup = FALSE)

Arguments

from
The color object to be converted.
gamma
The display gamma value.
fixup
Should the color be corrected to a valid RGB value before correction. The default is to convert out-of-gamut colors to the string "NA".

Value

  • A vector of character strings.

Details

The color objects are first converted to RGB color objects. They are then multiplied by 255 and rounded to obtain an integer value. These values are then converted to hexadecimal strings of the form "#RRGGBB" and suitable for use as color descriptions for R graphics. Out of gamut values are either corrected to valid RGB values by translating the the individual primary values so that they lie between 0 and 255.

See Also

hex2RGB, RGB, HSV, XYZ, LAB, polarLAB, LUV, polarLUV.

Examples

Run this code
hsv = HSV(seq(0,360,length=7)[-7], 1, 1)
barplot(rep(1,6), col=hex(hsv))

Run the code above in your browser using DataCamp Workspace