API: colorpicker YAHOO.util.Color (YUI Library)

# Yahoo! UI Library

### colorpicker 2.9.0

Yahoo! UI Library > colorpicker > YAHOO.util.Color
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.util.Color

Provides color conversion and validation utils

### Methods

#### dec2hex

`string dec2hex ( n )`
Converts an int 0...255 to hex pair 00...FF

Parameters:
  `n <int>` the number to convert

Returns: `string`
  the hex equivalent

#### hex2dec

`int hex2dec ( str )`
Converts a hex pair 00...FF to an int 0...255

Parameters:
  `str <string>` the hex pair to convert

Returns: `int`
  the decimal

#### hex2rgb

`[int, int, int] hex2rgb ( str )`
Converts a hex string to rgb

Parameters:
  `str <string>` the hex string

Returns: `[int, int, int]`
  an array containing the rgb values

#### hsv2rgb

`[int, int, int] hsv2rgb ( h , s , v )`
Converts HSV (h[0-360], s[0-1]), v[0-1] to RGB [255,255,255]

Parameters:
  `h <int|[int, float, float]>` the hue, or an array containing all three parameters
  `s <float>` the saturation
  `v <float>` the value/brightness

Returns: `[int, int, int]`
  the red, green, blue values in decimal.

#### real2dec

`int real2dec ( n )`
Converts 0-1 to 0-255

Parameters:
  `n <float>` the number to convert

Returns: `int`
  a number 0-255

#### rgb2hex

`string rgb2hex ( r , g , b )`
Converts decimal rgb values into a hex string 255,255,255 -> FFFFFF

Parameters:
  `r <int|[int, int, int]>` the red value, or an array containing all three parameters
  `g <int>` the green value
  `b <int>` the blue value

Returns: `string`
  the hex string

#### rgb2hsv

`[int, float, float] rgb2hsv ( r , g , b )`
Converts to RGB [255,255,255] to HSV (h[0-360], s[0-1]), v[0-1]

Parameters:
  `r <int|[int, int, int]>` the red value, or an array containing all three parameters
  `g <int>` the green value
  `b <int>` the blue value

Returns: `[int, float, float]`
  the value converted to hsv

#### websafe

`[int, int, int] websafe ( r , g , b )`
Returns the closest websafe color to the supplied rgb value.

Parameters:
  `r <int|[int, int, int]>` the red value, or an array containing all three parameters
  `g <int>` the green value
  `b <int>` the blue value

Returns: `[int, int, int]`
  an array containing the closes websafe rgb colors.

Copyright © 2011 Yahoo! Inc. All rights reserved.