# Class: ColorStyle

## ColorStyle(color)

#### new ColorStyle(color)

Simple solid color style represented and stored as a CSS color. Example value formats supported "rgb(0, 153, 255)" or "rgba(0, 153, 255, 0.3)" or "#0099ff" or "#0099ffaa" or "red".

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | string | Color of the style, if undefined it is set to black.

Source:
  - objects/style/ColorStyle.js, line 12

### Extends

- Style

### Members

#### cache :string|CanvasGradient|CanvasPattern

Cached style object pre-generated from previous calls. To avoid regenerating the same style object every cycle. Inherited classes should write their own get method that returns the style object and stores it in this property.

##### Type:

- string | CanvasGradient | CanvasPattern

Inherited From:
  - Style#cache
Source:
  - objects/style/Style.js, line 17

#### color :string

Color of this style object.

##### Type:

- string

Source:
  - objects/style/ColorStyle.js, line 21

#### needsUpdate :boolean

Indicates if the style object needs to be updated, should be used after applying changed to the style in order to generate a new object. Inherited classes should implement this functionality.

##### Type:

- boolean

Inherited From:
  - Style#needsUpdate
Source:
  - objects/style/Style.js, line 26

### Methods

#### get(context) → {string|CanvasGradient|CanvasPattern}

Get generated style object from style data and the drawing context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`context` | CanvasRenderingContext2D | Context being used to draw the object.

Overrides:
  - Style#get
Source:
  - objects/style/Style.js, line 35

##### Returns:

Return the canvas style object generated.

Type
  string | CanvasGradient | CanvasPattern

#### parse(data)

Parse the style attributes from JSON object data created with the serialize() method.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Serialized style data.

Overrides:
  - Style#parse
Source:
  - objects/style/Style.js, line 49

#### serialize() → {Object}

Serialize the style to JSON object, called by the objects using these styles.

Overrides:
  - Style#serialize
Source:
  - objects/style/Style.js, line 42

##### Returns:

Serialized style data.

Type
  Object