Contains helper functions for working with URL parameters, colors, etc.
- Copyright:
- Synaptory Fractal Traveler, 2025-2026
- License:
- MIT
- Source:
Members
(static, constant) SPLIT_FLOAT_METHOD :Object
Type:
- Object
- Source:
(static, constant) esc
Escapes HTML special characters in a string to prevent XSS attacks and rendering issues.
Converts &, <, and > to their HTML entity equivalents.
- Source:
(static, constant) isTouchDevice
Detects touch device
- Source:
(static, constant) splitFloat
Splits a 64-bit floating point number into two 32-bit parts
- Source:
(inner, constant) VELTKAMP_DEKKER_K
Veltkamp-Dekker splitting constant: 2^27 + 1 = 134217729
Pre-computed to avoid Math.pow() on every splitFloat call (called 4000+ times per orbit rebuild).
This is a common splitting point for 53-bit mantissa (JS number).
- Source:
Methods
(static) asyncDelay(timeout) → {Promise.<unknown>}
Helper function that returns a Promise that resolves after timeout.
Parameters:
| Name | Type | Description |
|---|---|---|
timeout |
number | in ms |
- Source:
Returns:
- Type
- Promise.<unknown>
(static) calculatePanDelta(currentX, currentY, lastX, lastY, rect, rotation, zoom) → {Array.<number>}
Calculates the change in pan based on the movement delta, the canvas rectangle, current zoom, and rotation.
Parameters:
| Name | Type | Description |
|---|---|---|
currentX |
number | The current X coordinate (clientX or touch.clientX). |
currentY |
number | The current Y coordinate. |
lastX |
number | The previous X coordinate. |
lastY |
number | The previous Y coordinate. |
rect |
DOMRect | The canvas bounding rectangle. |
rotation |
number | The current rotation (in radians). |
zoom |
number | The current zoom factor. |
- Source:
Returns:
An array [deltaPanX, deltaPanY] that should be added to the current pan.
- Type
- Array.<number>
(static) clearURLParams()
Clears browser URL, usually when it stops correspond with the position/zoom in the fractal
- Source:
(static) compareComplex(c1, c2, precisionopt) → {boolean}
Compares two complex numbers / arrays of two numbers with given precision
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
c1 |
COMPLEX | ||
c2 |
COMPLEX | ||
precision |
number |
<optional> |
- Source:
Returns:
true if numbers are equal, false if not
- Type
- boolean
(static) comparePalettes(p1, p2, precisionopt) → {boolean}
Compares two palettes / arrays of three numbers with given precision (transitively uses the compareComplex)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
p1 |
PALETTE | ||
p2 |
PALETTE | ||
precision |
number |
<optional> |
- Source:
Returns:
true if palettes are equal, false if not
- Type
- boolean
(static) ddAdd(dd, n) → {Object}
Adds a standard floating-point number to a double-double precision number.
This function mutates the input double-double object and maintains extended precision.
Parameters:
| Name | Type | Description |
|---|---|---|
dd |
Object | The double-double number to modify (mutated in place). |
n |
number | The standard floating-point number to add. |
- Source:
Returns:
The mutated double-double object with the sum.
- Type
- Object
(static) ddAddDD(a, b) → {Object}
Adds two double-double precision numbers and returns a new DD result.
Uses the Knuth two-sum algorithm for error-free addition.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
Object | First double-double number. |
b |
Object | Second double-double number. |
- Source:
Returns:
The sum as a new double-double number.
- Type
- Object
(static) ddMake(hiopt, loopt) → {Object}
Creates a double-double precision number object with high and low parts.
Used for extended precision arithmetic beyond standard 64-bit floating point.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
hi |
number |
<optional> |
0 | The high-order (primary) part of the number. |
lo |
number |
<optional> |
0 | The low-order (error correction) part of the number. |
- Source:
Returns:
A double-double precision number object.
- Type
- Object
(static) ddSet(dd, n) → {Object}
Sets the value of a double-double precision object from a standard number.
This effectively resets the high-precision value to a single 64-bit float,
clearing any existing low-precision error bits.
Parameters:
| Name | Type | Description |
|---|---|---|
dd |
Object | The double-double object to modify. |
n |
number | The number to assign to the high part. |
- Source:
Returns:
The mutated double-double object.
- Type
- Object
(static) ddSubDD(a, b) → {Object}
Subtracts two double-double precision numbers (a - b) and returns a new DD result.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
Object | The minuend (number to subtract from). |
b |
Object | The subtrahend (number to subtract). |
- Source:
Returns:
The difference (a - b) as a new double-double number.
- Type
- Object
(static) ddValue(dd) → {number}
Returns the standard 64-bit floating-point approximation of a double-double number.
This combines the high and low parts to reconstruct the full precision value.
Parameters:
| Name | Type | Description |
|---|---|---|
dd |
Object | The double-double number object with high and low precision parts. |
- Source:
Returns:
The combined floating-point value.
- Type
- number
(static) degToRad(degrees) → {number}
Converts degrees from JSON to Radians for GLSL uniforms
Parameters:
| Name | Type | Description |
|---|---|---|
degrees |
number |
- Source:
Returns:
radians
- Type
- number
(static) destroyArrayOfButtons(buttons)
Removes array of buttons from the scene and clears it.
Parameters:
| Name | Type | Description |
|---|---|---|
buttons |
Array.<HTMLButtonElement> |
- Source:
(static) easeInOut(time) → {number}
Helper function for ease-in-out timing. This function accelerates in the first half (using 2*t²) and decelerates in
the second half.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | A value between 0 and 1 representing the progress. |
- Source:
Returns:
The eased value.
- Type
- number
(static) easeInOutCubic(time) → {number}
Helper function for ease-in-out timing. The cubic version tends to have a smoother acceleration at the beginning and
a gentler deceleration at the end, to start more gradually and then slow down more smoothly toward the end.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | A value between 0 and 1 representing the progress. |
- Source:
Returns:
The eased value.
- Type
- number
(static) easeInOutQuint(time) → {number}
Helper function for ease-in-out timing using a quintic curve.
This function starts gradually, accelerates, then decelerates more gently near the end.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | A value between 0 and 1 representing the progress. |
- Source:
Returns:
The eased value.
- Type
- number
(static) expandComplexToString(c, precision, withIopt) → {string}
Generates string in [x, yi] format from the given complex number. Trailing zeroes are trimmed.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
c |
COMPLEX | ||
precision |
number | Decimal point precision | |
withI |
boolean |
<optional> |
Append "i" to the imaginary member? Ignored if zero. |
- Source:
Returns:
[x, yi]|[x, 0]|[?, ?]
- Type
- string
(static) getAnimationDuration(seed, current, target, weightsopt) → {number}
Computes a duration based on the travel distance between current and target parameters. Iterates over each property
in target (assuming current and target have the same structure)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
seed |
number | A scaling factor to adjust the overall duration. | |
current |
object | An object with current values | |
target |
object | An object with target values | |
weights |
object |
<optional> |
Optional weights |
- Source:
Returns:
The computed duration.
- Type
- number
(static) getFractalName(type)
Returns the name of the fractal mode.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
number |
- Source:
(static) hexToRGB(hex, normalizeopt) → {Object|null}
Converts HTML hex color notation to rgb object
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
hex |
string | HTML hex color | |
normalize |
number |
<optional> |
interval to normalize onto |
- Source:
Returns:
- Type
- Object | null
(static) hexToRGBArray(hex, normalizeopt) → {Array.<number>|null}
Converts HTML hex color notation to rgb array
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
hex |
string | HTML hex color | |
normalize |
number |
<optional> |
interval to normalize onto |
- Source:
Returns:
[r, g, b]
- Type
- Array.<number> | null
(static) hsbToRgb(h, s, b) → {PALETTE}
HSB to RGB conversion helper function
Parameters:
| Name | Type | Description |
|---|---|---|
h |
Hue | |
s |
Saturation | |
b |
Brightness |
- Source:
Returns:
rgb
- Type
- PALETTE
(static) hslToRgb(h, s, l) → {PALETTE}
Convert HSL (h in [0,1], s in [0,1], l in [0,1]) to RGB (each channel in [0,1])
Parameters:
| Name | Type | Description |
|---|---|---|
h |
number | Hue |
s |
number | Saturation |
l |
number | Lightness |
- Source:
Returns:
[r, g ,b]
- Type
- PALETTE
(static) isMobileDevice() → {boolean}
Detects mobile device
- Source:
Returns:
if the user device is mobile
- Type
- boolean
(static) lerp(start, end, time) → {number}
Helper function for linear interpolation
Parameters:
| Name | Type | Description |
|---|---|---|
start |
number | |
end |
number | |
time |
number | A value between 0 and 1 representing the progress. |
- Source:
Returns:
- Type
- number
(static) loadFractalParamsFromURL() → {URL_PRESET}
Fetches and recalculates coords and zoom from URL and sets them to the fractalApp instance
- Source:
Returns:
- Type
- URL_PRESET
(static) normalizeRotation(rotation) → {number}
Normalizes rotation into into [0, 2*PI] interval
Parameters:
| Name | Type | Description |
|---|---|---|
rotation |
number | in rad |
- Source:
Returns:
rotation in rad
- Type
- number
(static) quickTwoSum(a, b) → {Object}
Computes the error-free sum of two floating-point numbers where |a| >= |b|.
This is a faster variant of twoSum that assumes the first argument has greater magnitude.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
number | The larger magnitude number (must satisfy |a| >= |b|). |
b |
number | The smaller magnitude number to add. |
- Source:
Returns:
An object containing the sum (s) and the rounding error (err).
- Type
- Object
(static) rgbToHsl(r, g, b) → {Array.<number, number, number>}
Converts RGB (each in [0,1]) to HSL (h in [0,1], s in [0,1], l in [0,1])
Parameters:
| Name | Type | Description |
|---|---|---|
r |
number | Red |
g |
number | Green |
b |
number | Blue |
- Source:
Returns:
[h, s, l]
- Type
- Array.<number, number, number>
(static) twoSum(a, b) → {Object}
Computes the error-free sum of two floating-point numbers using Knuth's two-sum algorithm.
Returns both the sum and the rounding error, enabling extended precision arithmetic.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
number | The first number to sum. |
b |
number | The second number to sum. |
- Source:
Returns:
An object containing the sum (s) and the rounding error (err).
- Type
- Object
(static) updateURLParams(mode, px, py, cx, cy, zoom, rotation, paletteId)
Updates browser URL with params of the selected point and zoom in the fractal
Parameters:
| Name | Type | Description |
|---|---|---|
mode |
FRACTAL_TYPE | |
px |
number | panX |
py |
number | panY |
cx |
number | null | Julia only |
cy |
number | null | Julia only |
zoom |
number | |
rotation |
number | |
paletteId |
string | null | optional palette ID |
- Source:
(inner) splitFloatED(value) → {Object}
GPU Emulated Double. This is the standard approach for rendering high-precision or astronomical visualizations).
Parameters:
| Name | Type | Description |
|---|---|---|
value |
- Source:
Returns:
- Type
- Object
(inner) splitFloatVD(value) → {Object}
The Veltkamp-Dekker Split: This implementation is the classic Veltkamp-Dekker algorithm. It is designed to split
a 64-bit double into two "half-precision" doubles so that their product can be calculated without losing precision.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | A standard JavaScript 64-bit number. |
- Source:
Returns:
- Type
- Object