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.

This renderer is currently used only in the web app when "Correct Brightness" is enabled, and is not used in generation of Gallery images and the automatic tests.

Constructor

new FloatColorRenderer()

Source:

Members

MAX_CACHE_SIZE :number

Maximum number of elements in the cache before flushing.

Type:
  • number
Source:

Methods

begin()

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

Source:

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

Compile a shader.

Parameters:
Name Type Description
gl WebGLRenderingContext
source string
type number
Source:
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:

destroy()

Destroy the renderer and release resources.

Source:

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:

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:

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:

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:

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:

initializeFramebuffer()

Initialize the framebuffer and textures.

Source:

initializeShaders()

Initialize shaders.

Source:

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

Preprocess color for gamma correction and normalization.

Parameters:
Name Type Description
color Array.<number>
Source:
Returns:
Type
Array.<number>