# Class: FloatColorRenderer

## FloatColorRenderer()

An experimental canvas renderer for the light layer with the same API as `CanvasRenderer`, but uses the WebGL floating point texture and properly calculates color mixtures. This largely solves the issue of brightness and color inconsistency issue in this simulator, especially whe "Simulate Colors" is enabled (where the performace issue is also solved). Additionally, this renderer allows for different color modes (as defined in `Scene`, but the 'legacy' mode with `simulateColors` enabled is split into 'legacy_color').

This renderer is currently used only in the web app when the "Float Color Renderer" experimental feature is enabled, and is not used in generation of Gallery images and the automatic tests.

## Constructor

#### new FloatColorRenderer()

Source:
  - FloatColorRenderer.js, line 23

### Members

#### MAX_CACHE_SIZE :number

Maximum number of elements in the cache before flushing.

##### Type:

- number

Source:
  - FloatColorRenderer.js, line 29

### Methods

#### begin()

Begin the drawing process. This method is called at the beginning of each frame.

Source:
  - FloatColorRenderer.js, line 444

#### compileShader(gl, source, type) → {WebGLShader}

Compile a shader.

##### Parameters:

Name | Type | Description
--- | --- | ---
`gl` | WebGLRenderingContext |
`source` | string |
`type` | number |

Source:
  - FloatColorRenderer.js, line 427

##### Returns:

Type
  WebGLShader

#### createRectangleFromLine(p1, p2, widthopt)

Create a rectangle from a line segment. Since WebGL lineWidth is not widely supported, this method creates a rectangle with the given width to render the line segment or ray.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`p1` | Point |  |  |
`p2` | Point |  |  |
`width` | number | <optional> | 1 |

Source:
  - FloatColorRenderer.js, line 928

#### destroy()

Destroy the renderer and release resources.

Source:
  - FloatColorRenderer.js, line 995

#### drawDashedSegment(s, coloropt, lineDashopt)

Draw a dashed segment.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`s` | Line |  |  |
`color` | Array.<number> | <optional> | [0, 0, 0, 1] |
`lineDash` | Array.<number> | <optional> | [] |

Source:
  - FloatColorRenderer.js, line 624

#### drawPoint(p, coloropt, sizeopt)

Draw a point.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`p` | Point |  |  |
`color` | Array.<number> | <optional> | [0, 0, 0, 1] |
`size` | number | <optional> | 5 |

Source:
  - FloatColorRenderer.js, line 458

#### drawRay(r, coloropt, showArrowopt, lineDashopt)

Draw a ray.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`r` | Line |  |  |
`color` | Array.<number> | <optional> | [0, 0, 0, 1] |
`showArrow` | boolean | <optional> | false |
`lineDash` | Array.<number> | <optional> | [] |

Source:
  - FloatColorRenderer.js, line 475

#### drawSegment(s, coloropt, showArrowopt, lineDashopt)

Draw a segment.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`s` | Line |  |  |
`color` | Array.<number> | <optional> | [0, 0, 0, 1] |
`showArrow` | boolean | <optional> | false |
`lineDash` | Array.<number> | <optional> | [] |

Source:
  - FloatColorRenderer.js, line 674

#### flush()

Flush the caches and render the accumulated rays, segments, and points. This method is called when the cache size exceeds the maximum cache size, when the simulation is paused, or when the simulation is completed.

Source:
  - FloatColorRenderer.js, line 787

#### initializeFramebuffer()

Initialize the framebuffer and textures.

Source:
  - FloatColorRenderer.js, line 78

#### initializeShaders()

Initialize shaders.

Source:
  - FloatColorRenderer.js, line 122

#### preprocessColor(color) → {Array.<number>}

Preprocess color for gamma correction and normalization.

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | Array.<number> |

Source:
  - FloatColorRenderer.js, line 961

##### Returns:

Type
  Array.<number>