Class: MandelbrotRenderer

MandelbrotRenderer()

MandelbrotRenderer

Constructor

new MandelbrotRenderer()

This module defines a MandelbrotRenderer class that inherits from fractalRenderer, implements the shader fragment code for the Mandelbrot set fractal and sets preset zoom-ins.
Author:
  • Radim Brnka
Source:

Extends

Classes

MandelbrotRenderer

Members

DEFAULT_PAN :COMPLEX

Type:
  • COMPLEX
Overrides:
Source:

PRESETS

Mandelbrot-specific presets
Overrides:
Source:

colorPalette :PALETTE

Type:
  • PALETTE
Overrides:
Source:

iterations :number

Determines the level of fractal rendering detail
Type:
  • number
Overrides:
Source:

pan :COMPLEX

Type:
  • COMPLEX
Overrides:
Source:

rotation :number

Rotation in rad
Type:
  • number
Overrides:
Source:

vertexShaderSource

Vertex shader initialization snippet
Overrides:
Source:

zoom :number

Zoom. Lower number = higher zoom.
Type:
  • number
Overrides:
Source:

Methods

(async) animateColorPaletteTransition(newPalette, durationopt, coloringCallbackopt) → {Promise.<void>}

Smoothly transitions fractalApp.colorPalette from its current value to the provided newPalette over the specified duration (in milliseconds).
Parameters:
Name Type Attributes Default Description
newPalette PALETTE The target palette as [r, g, b] (each in [0,1]).
duration number <optional>
250 Duration of the transition in milliseconds.
coloringCallback function <optional>
null A method called at every animation step
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateDemo(random) → {Promise.<void>}

Animates infinite demo loop of traveling to the presets
Parameters:
Name Type Default Description
random boolean true Determines whether presets are looped in order from 1-9 or ordered randomly
Source:
Returns:
Type
Promise.<void>

(async) animateFullColorSpaceCycle(durationopt, coloringCallbackopt) → {Promise.<void>}

Animates fractalApp.colorPalette by cycling through the entire color space. The palette will continuously change hue from 0 to 360 degrees and starts from the current palette
Parameters:
Name Type Attributes Default Description
duration number <optional>
15000 Duration (in milliseconds) for one full color cycle.
coloringCallback function <optional>
null
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateInfiniteRotation(direction, step) → {Promise.<void>}

Parameters:
Name Type Default Description
direction ROTATION_DIRECTION
step number 0.001 Speed in rad/frame
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animatePanAndZoomTo(targetPan, targetZoom, durationopt, easeFunction) → {Promise.<void>}

Animates pan and zoom simultaneously.
Parameters:
Name Type Attributes Default Description
targetPan COMPLEX
targetZoom number
duration number <optional>
1000 in milliseconds
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animatePanThenZoomTo(targetPan, targetZoom, panDuration, zoomDuration, easeFunction) → {Promise.<void>}

Animates sequential pan and then zooms into the target location.
Parameters:
Name Type Description
targetPan COMPLEX
targetZoom number
panDuration number in milliseconds
zoomDuration number in milliseconds
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animatePanTo(targetPan, durationopt, easeFunction) → {Promise.<void>}

Animates pan from current position to the new one
Parameters:
Name Type Attributes Default Description
targetPan COMPLEX
duration <optional>
200 in ms
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animatePanZoomRotationTo(targetPan, targetZoom, targetRotation, durationopt, easeFunction) → {Promise.<void>}

Animates pan, zoom and rotation simultaneously
Parameters:
Name Type Attributes Default Description
targetPan COMPLEX
targetZoom number
targetRotation number
duration number <optional>
500 in milliseconds
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateRotationTo(targetRotation, durationopt, easeFunction) → {Promise.<void>}

Animates to target rotation. Rotation is normalized into [0, 2*PI] interval
Parameters:
Name Type Attributes Default Description
targetRotation number
duration number <optional>
500 in ms
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateTravelToPreset(preset, zoomOutDurationopt, zoomInDurationopt) → {Promise.<void>}

Animates travel to a preset. It first zooms out to the default zoom, then rotates, then animates pan and zoom-in. If any of the final params is the same as the target, it won't animate it.
Parameters:
Name Type Attributes Default Description
preset MANDELBROT_PRESET An instance-specific object to define exact spot in the fractal
zoomOutDuration number <optional>
1000 in ms
zoomInDuration number <optional>
3500 in ms
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateTravelToPresetWithRandomRotation(preset, zoomOutDuration, panDuration, zoomInDuration)

Animate travel to a preset with random rotation. This method waits for three stages: 1. Zoom-out to default zoom with rotation. 2. Pan transition. 3. Zoom-in with rotation.
Parameters:
Name Type Description
preset MANDELBROT_PRESET The target preset object with properties: pan, c, zoom, rotation.
zoomOutDuration number Duration (ms) for the zoom-out stage.
panDuration number Duration (ms) for the pan stage.
zoomInDuration number Duration (ms) for the zoom-in stage.
Overrides:
Source:

(async) animateZoomRotationTo(targetZoom, targetRotation, durationopt, easeFunction) → {Promise.<void>}

Animates to target zoom and rotation simultaneously. Rotation is normalized into [0, 2*PI] interval
Parameters:
Name Type Attributes Default Description
targetZoom number
targetRotation number
duration number <optional>
500 in ms
easeFunction EASE_TYPE | function
Overrides:
Source:
Returns:
Type
Promise.<void>

(async) animateZoomTo(targetZoom, durationopt, easeFunction) → {Promise.<void>}

Animates to target zoom without panning.
Parameters:
Name Type Attributes Default Description
targetZoom number
duration number <optional>
500 in ms
easeFunction EASE_TYPE | function If none is provided, it defaults to exponential.
Overrides:
Source:
Returns:
Type
Promise.<void>

compileShader(source, type) → {WebGLShader|null}

Compiles the shader code
Parameters:
Name Type Description
source string
type GLenum
Overrides:
Source:
Returns:
Type
WebGLShader | null

createFragmentShaderSource()

Defines the shader code for rendering the fractal shape
Overrides:
Source:

destroy()

Destructor
Overrides:
Source:

draw()

Draws the fractal's and sets basic uniforms. Customize iterations number to determine level of detail.
Overrides:
Source:

init()

WebGL init & initial uniforms setting
Overrides:
Source:

initGLProgram()

Initializes the WebGL program, shaders and sets initial position
Overrides:
Source:

onAnimationFinished()

Default callback after every animation that requires on-screen info update
Overrides:
Source:

reset()

Resets the fractal to its initial state (default pan, zoom, palette, rotation, etc.), resizes and redraws.
Overrides:
Source:

resizeCanvas()

Updates the canvas size based on the current visual viewport and redraws the fractal
Overrides:
Source:

screenToFractal(screenX, screenY) → {COMPLEX}

Calculates coordinates from screen point [x, y] to the fractal scale [x, yi]
Parameters:
Name Type Description
screenX number
screenY number
Overrides:
Source:
Returns:
fractal plane coords [x, yi]
Type
COMPLEX

stopAllNonColorAnimations()

Stops all currently running animations that are not a color transition
Overrides:
Source:

stopCurrentColorAnimations()

Stops currently running color animation
Overrides:
Source:

stopCurrentPanAnimation()

Stops currently running pan animation
Overrides:
Source:

stopCurrentRotationAnimation()

Stops currently running rotation animation
Overrides:
Source:

stopCurrentZoomAnimation()

Stops currently running zoom animation
Overrides:
Source:

stopDemo()

Stops current demo and resets demo variables
Overrides:
Source:

updateUniforms()

Updates uniforms (should be done on every redraw)
Overrides:
Source: