Contains helper functions for working with URL parameters, colors, etc.
- 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) 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) 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) isTouchDevice() → {boolean}
Detects touch device
- Source:
Returns:
- 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) 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) updateURLParams(mode, px, py, cx, cy, zoom, rotation)
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 |
- Source: