Constructor
new JuliaRenderer()
This module defines a JuliaRenderer class that inherits from fractalRenderer, implements the shader fragment code for the Julia set fractal and sets preset zoom-ins.
- Source:
Extends
Classes
Members
DEFAULT_C :COMPLEX
Type:
- COMPLEX
- Source:
DEFAULT_PAN :COMPLEX
Type:
- COMPLEX
- Overrides:
- Source:
DIVES :Array.<DIVE>
Type:
- Array.<DIVE>
- Source:
PRESETS :Array.<JULIA_PRESET>
Type:
- Array.<JULIA_PRESET>
- Overrides:
- Source:
c :COMPLEX
Type:
- COMPLEX
- 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() → {Promise.<void>}
Animates infinite demo loop with oscillating c between predefined values
- Source:
Returns:
- Type
- Promise.<void>
(async) animateDive(dive) → {Promise.<void>}
Infinite animation of the dive (c-param interpolations)
Parameters:
Name | Type | Description |
---|---|---|
dive |
DIVE |
- 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) animateInnerStopsTransition(toPalette, durationopt, callbackopt) → {Promise.<void>}
Smoothly transitions the inner color stops (used by the shader for inner coloring)
from the current value to the provided toPalette over the specified duration.
Also updates the colorPalette to match the theme (using the first stop, for example).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
toPalette |
JULIA_PALETTE | The target theme as an array of numbers (e.g., 15 numbers for 5 stops). | ||
duration |
number |
<optional> |
250 | Duration of the transition in milliseconds. |
callback |
function |
<optional> |
null | A callback invoked when the transition completes. |
- 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) animateToC(targetCopt, durationopt, easeFunction) → {Promise.<void>}
Animates Julia from current C to target C
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
targetC |
COMPLEX |
<optional> |
Defaults to default C | |
duration |
number |
<optional> |
500 | in ms |
easeFunction |
EASE_TYPE | function |
- Source:
Returns:
- Type
- Promise.<void>
(async) animateToZoomAndC(targetZoomopt, targetCopt, durationopt, easeFunction) → {Promise.<void>}
Animates Julia from current C and zoom to target C and zoom
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
targetZoom |
number |
<optional> |
Target zoom | |
targetC |
COMPLEX |
<optional> |
Defaults to default C | |
duration |
number |
<optional> |
500 | in ms |
easeFunction |
EASE_TYPE | function |
- Source:
Returns:
- Type
- Promise.<void>
(async) animateTravelToPreset(preset, durationopt) → {Promise.<void>}
Animates travel to a preset.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
preset |
JULIA_PRESET | |||
duration |
number |
<optional> |
500 | 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 with rotation.
2. Pan transition.
3. Zoom-in with rotation.
Parameters:
Name | Type | Description |
---|---|---|
preset |
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:
getNextColorThemeId() → {string}
Returns id/title of the next color theme in the themes array.
- Source:
Returns:
- Type
- string
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:
stopCurrentCAnimation()
Stops currently running pan animation
- 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: