# Drawable

#### new Drawable(idnon-null)

To Do:
  - double-buffer all rendering state (position, skin, effects, etc.)

An object which can be drawn by the renderer.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | int | This Drawable's unique ID.

### Members

#### _convexHullPoints

To Do:
  - move convex hull functionality, maybe bounds functionality overall, to Skin classes

#### (non-null) _id :int

##### Type:

- int

#### (private) _uniforms :Object.<string, *>

The uniforms to be used by the vertex and pixel shaders. Some of these are used by other parts of the renderer as well.

##### Type:

- Object.<string, *>

#### id

#### scale

#### skin

### Methods

#### (static) color3bToID(r, g, b) → {int}

Calculate the ID number represented by the given color. If all components of the color are zero, the result will be RenderConstants.ID_NONE; otherwise the result will be a valid ID.

##### Parameters:

Name | Type | Description
--- | --- | ---
`r` | int | The red value of the color, in the range [0,255].
`g` | int | The green value of the color, in the range [0,255].
`b` | int | The blue value of the color, in the range [0,255].

##### Returns:

The ID represented by that color.

Type
  int

#### (static) color4fFromID(id) → {Array.<number>}

Calculate a color to represent the given ID number. At least one component of the resulting color will be non-zero if the ID is not RenderConstants.ID_NONE.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | int | The ID to convert.

##### Returns:

An array of [r,g,b,a], each component in the range [0,1].

Type
  Array.<number>

#### (private) _calculateTransform()

Calculate the transform to use when rendering this Drawable.

#### (private) _skinWasAltered()

Respond to an internal change in the current Skin.

#### dispose()

Dispose of this Drawable. Do not use it after calling this method.

#### getAABB() → (non-null) {Rectangle}

Get the rough axis-aligned bounding box for the Drawable. Calculated by transforming the skin's bounds. Note that this is less precise than the box returned by `getBounds`, which is tightly snapped to account for a Drawable's transparent regions. `getAABB` returns a much less accurate bounding box, but will be much faster to calculate so may be desired for quick checks/optimizations.

##### Returns:

Rough axis-aligned bounding box for Drawable.

Type
  Rectangle

#### getBounds() → (non-null) {Rectangle}

Get the precise bounds for a Drawable. This function applies the transform matrix to the known convex hull, and then finds the minimum box along the axes. Before calling this, ensure the renderer has updated convex hull points.

##### Returns:

Bounds for a tight box around the Drawable.

Type
  Rectangle

#### getEnabledEffects() → {int}

##### Returns:

A bitmask identifying which effects are currently in use.

Type
  int

#### getFastBounds() → (non-null) {Rectangle}

Return the best Drawable bounds possible without performing graphics queries. I.e., returns the tight bounding box when the convex hull points are already known, but otherwise return the rough AABB of the Drawable.

##### Returns:

Bounds for the Drawable.

Type
  Rectangle

#### getUniforms() → {object.<string, *>}

##### Returns:

the shader uniforms to be used when rendering this Drawable.

Type
  object.<string, *>

#### getVisible() → {boolean}

##### Returns:

whether this Drawable is visible.

Type
  boolean

#### needsConvexHullPoints() → {boolean}

Whether the Drawable needs convex hull points provided by the renderer.

##### Returns:

True when no convex hull known, or it's dirty.

Type
  boolean

#### setConvexHullDirty()

Set the convex hull to be dirty. Do this whenever the Drawable's shape has possibly changed.

#### setConvexHullPoints(points)

Set the convex hull points for the Drawable.

##### Parameters:

Name | Type | Description
--- | --- | ---
`points` | Array.<Array.<number>> | Convex hull points, as [[x, y], ...]

#### setTransformDirty()

Mark this Drawable's transform as dirty. It will be recalculated next time it's needed.

#### updateProperties(properties)

Update the position, direction, scale, or effect properties of this Drawable.

##### Parameters:

Name | Type | Description
--- | --- | ---
`properties` | object.<string, *> | The new property values to set.