For up to date documentation and features, visit http://docs.sencha.com/ext-js/4-0

## Sencha Documentation

# Ext.draw.Color

Represents an RGB color and provides helper functions get color components in HSL color space.

Defined By

### Config Options

#### Other Configs

Ext.draw.Color
view source
lightnessFactor : Number

The default factor to compute the lighter or darker color. Defaults to 0.2.

The default factor to compute the lighter or darker color. Defaults to 0.2.

Defined By

### Methods

Ext.draw.Color
view source
Color( Number red, Number green, Number blue) : void

### Parameters

- red : Number

  Red component (0..255)

- green : Number

  Green component (0..255)

- blue : Number

  Blue component (0..255)

### Returns

- void

Ext.draw.Color
view source
fromHSL( Number h, Number s, Number l) : void

Create a new color based on the specified HSL values.

Create a new color based on the specified HSL values.

### Parameters

- h : Number

  Hue component (0..359)

- s : Number

  Saturation component (0..1)

- l : Number

  Lightness component (0..1)

### Returns

- void

  Ext.draw.Color

Ext.draw.Color
view source
fromString( String str) : void
Parse the string and create a new color. Supported formats: '#rrggbb', '#rgb', and 'rgb(r,g,b)'. If the string is n...

Parse the string and create a new color.

Supported formats: '#rrggbb', '#rgb', and 'rgb(r,g,b)'.

If the string is not recognized, an undefined will be returned instead.

### Parameters

- str : String

  Color in string.

### Returns

- void

  Ext.draw.Color

Ext.draw.Color
view source
getBlue : Number

Get the blue component of the color, in the range 0..255.

Get the blue component of the color, in the range 0..255.

### Returns

- Number

Ext.draw.Color
view source
getDarker( Number factor) : void

Return a new color that is darker than this color.

Return a new color that is darker than this color.

### Parameters

- factor : Number

  Darker factor (0..1), default to 0.2

### Returns

- void

  Ext.draw.Color

Ext.draw.Color
view source
getGrayscale : Number

Returns the gray value (0 to 255) of the color.

The gray value is calculated using the formula r0.3 + g0.59 + b*0.11.

Returns the gray value (0 to 255) of the color.

The gray value is calculated using the formula r0.3 + g0.59 + b*0.11.

### Returns

- Number

Ext.draw.Color
view source
getGreen : Number

Get the green component of the color, in the range 0..255.

Get the green component of the color, in the range 0..255.

### Returns

- Number

Ext.draw.Color
view source
getHSL : Array

Get the equivalent HSL components of the color.

Get the equivalent HSL components of the color.

### Returns

- Array

Ext.draw.Color
view source
getLighter( Number factor) : void

Return a new color that is lighter than this color.

Return a new color that is lighter than this color.

### Parameters

- factor : Number

  Lighter factor (0..1), default to 0.2

### Returns

- void

  Ext.draw.Color

Ext.draw.Color
view source
getRGB : Array

Get the RGB values.

Get the RGB values.

### Returns

- Array

Ext.draw.Color
view source
getRed : Number

Get the red component of the color, in the range 0..255.

Get the red component of the color, in the range 0..255.

### Returns

- Number

Ext.draw.Color
view source
toHex( String|Array color) : String

Convert a color to hexadecimal format.

Convert a color to hexadecimal format.

### Parameters

- color : String|Array

  The color value (i.e 'rgb(255, 255, 255)', 'color: #ffffff'). Can also be an Array, in this case the function handles the first member.

### Returns

- String

  The color in hexadecimal format.

Ext.draw.Color
view source
toString : String

Return the color in the hex format, i.e. '#rrggbb'.

Return the color in the hex format, i.e. '#rrggbb'.

### Returns

- String