# ShaderManager

#### new ShaderManager(gl)

##### Parameters:

Name | Type | Description
--- | --- | ---
`gl` | WebGLRenderingContext | WebGL rendering context to create shaders for

### Members

#### (static, readonly) DRAW_MODE :string

##### Properties:

Name | Type | Description
--- | --- | ---
`default` | string | Draw normally.
`silhouette` | string | Draw a silhouette using a solid color.
`colorMask` | string | Draw only the parts of the drawable which match a particular color.

The available draw modes.

##### Type:

- string

#### (static) EFFECT_INFO :ShaderManager.Effect

##### Properties:

Name | Type | Description
--- | --- | ---
`color` | ShaderManager.Effect | Color effect
`fisheye` | ShaderManager.Effect | Fisheye effect
`whirl` | ShaderManager.Effect | Whirl effect
`pixelate` | ShaderManager.Effect | Pixelate effect
`mosaic` | ShaderManager.Effect | Mosaic effect
`brightness` | ShaderManager.Effect | Brightness effect
`ghost` | ShaderManager.Effect | Ghost effect

Mapping of each effect name to info about that effect.

##### Type:

- ShaderManager.Effect

#### (static) EFFECTS :Array

The name of each supported effect.

##### Type:

- Array

#### (private) _shaderCache :Object.<ShaderManager.DRAW_MODE, Array.<ProgramInfo>>

The cache of all shaders compiled so far, filled on demand.

##### Type:

- Object.<ShaderManager.DRAW_MODE, Array.<ProgramInfo>>

### Methods

#### (private) _buildShader(drawMode, effectBits) → {ProgramInfo}

Build the shader for a particular set of active effects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`drawMode` | ShaderManager.DRAW_MODE | Draw normally, silhouette, etc.
`effectBits` | int | Bitmask representing the enabled effects.

##### Returns:

The new shader's program info.

Type
  ProgramInfo

#### getShader(drawMode, effectBits) → {ProgramInfo}

Fetch the shader for a particular set of active effects. Build the shader if necessary.

##### Parameters:

Name | Type | Description
--- | --- | ---
`drawMode` | ShaderManager.DRAW_MODE | Draw normally, silhouette, etc.
`effectBits` | int | Bitmask representing the enabled effects.

##### Returns:

The shader's program info.

Type
  ProgramInfo

### Type Definitions

#### Effect

##### Properties:

Name | Type | Description
--- | --- | ---
`mask` | int | The bit in 'effectBits' representing the effect.
`converter` | function | A conversion function which takes a Scratch value (generally in the range 0..100 or -100..100) and maps it to a value useful to the shader. This mapping may not be reversible.
`shapeChanges` | boolean | Whether the effect could change the drawn shape.

##### Type:

- object