Members
(constant) E :number
Euler's constant.
Type:
- number
- Source:
(constant) PHI :number
Golden ratio.
Type:
- number
- Source:
(constant) availableLangKeys
list of language keys supported by the dictionary
(constant) b64Digits :string
Digits used for base64 style encoding.
Type:
- string
- Source:
(constant) dictionary :Object.<string, {nl:string, en:string}>
Holds all translatable "hot strings".
The top level keys are replacement tokens used inside the GUI.
The dictionary keys should be sorted alphabetically in reverse order, so that the longest keys are replaced first.
(Use the VS Code "Sort JS Object keys" extension to sort the keys.)
Type:
- Object.<string, {nl:string, en:string}>
(constant) lang :Lang
Global instance of Lang used throughout the GUI for translations.
Type:
(constant) language :string
Type:
- string
Methods
bezierFilletControlPoints(filletStart, filletEnd, cen) → {Array.<Vec2D>}
Calculate control points for a fillet bezier curve.
Parameters:
Name | Type | Description |
---|---|---|
filletStart |
Vec2D | |
filletEnd |
Vec2D | |
cen |
Vec2D |
- Source:
Returns:
- Type
- Array.<Vec2D>
capitalizeFirstLetter(inputString) → {string}
Capitalise the first character of a string.
Parameters:
Name | Type | Description |
---|---|---|
inputString |
string |
- Source:
Returns:
- Type
- string
colorToHexString(col, doAlphaopt) → {string}
Convert a p5 color to a hex string.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
col |
p5.Color | |||
doAlpha |
boolean |
<optional> |
false |
- Source:
Returns:
- Type
- string
computeRoughSizeOfObject(object) → {number}
Roughly estimate the memory footprint of a JavaScript object.
Parameters:
Name | Type | Description |
---|---|---|
object |
object |
- Source:
Returns:
Size in bytes
- Type
- number
constrainAngle(angle, anchorAngle, constraint) → {number}
Constrain an angle around an anchor by a maximum deviation.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | |
anchorAngle |
number | |
constraint |
number |
- Source:
Returns:
- Type
- number
copyCanvasToClipboard()
Copy the current canvas bitmap to the system clipboard.
- Source:
fromB64(s64) → {number}
Parse a base64-like string back into a number.
Parameters:
Name | Type | Description |
---|---|---|
s64 |
string |
- Source:
Returns:
- Type
- number
gaussian(x) → {number}
Standard gaussian function e^(-x^2).
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
gaussianAngular(x) → {number}
Mix between gaussian and gaussianSharp.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
gaussianSharp(x) → {number}
Absolute value gaussian for a sharper peak.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
gaussianWobble(x) → {number}
Highly peaked gaussian used for noise wobbles.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
getTimestamp() → {string}
Generate a compact base64 timestamp string.
- Source:
Returns:
- Type
- string
getUNIX() → {number}
Get the current UNIX timestamp in seconds.
- Source:
Returns:
- Type
- number
getWheelDistance(evt) → {number}
Cross-browser helper for retrieving wheel delta.
Parameters:
Name | Type | Description |
---|---|---|
evt |
WheelEvent |
- Source:
Returns:
- Type
- number
hashThreeIntegers(a, b, c) → {number}
Combine three integers into a single hash value.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | |
b |
number | |
c |
number |
- Source:
Returns:
- Type
- number
imageCentered(img, doFill)
Draw an image fitted to the canvas centre.
Parameters:
Name | Type | Description |
---|---|---|
img |
p5.Image | Image to draw. |
doFill |
boolean | Fit or contain flag. |
- Source:
inPg(v, offsopt) → {boolean}
Check whether a vector lies within the offscreen graphics buffer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
v |
Vec2D | |||
offs |
number |
<optional> |
0 |
- Source:
Returns:
- Type
- boolean
intersectionPoint(lineA, lineB) → {Vec2D}
Convenience wrapper returning the intersection of two Line2D lines.
Parameters:
Name | Type | Description |
---|---|---|
lineA |
Line2D | |
lineB |
Line2D |
- Source:
Returns:
- Type
- Vec2D
isArraysEqual(a, b) → {boolean}
Check if two arrays contain the same values in the same order.
Parameters:
Name | Type | Description |
---|---|---|
a |
Array | |
b |
Array |
- Source:
Returns:
- Type
- boolean
isInBounds(v, x, y, w, h, offsopt) → {boolean}
Check whether a vector lies within rectangular bounds.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
v |
Vec2D | |||
x |
number | |||
y |
number | |||
w |
number | |||
h |
number | |||
offs |
number |
<optional> |
0 | Optional margin |
- Source:
Returns:
- Type
- boolean
isInCanvas(v, offsopt) → {boolean}
Check whether a vector lies within the main canvas.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
v |
Vec2D | |||
offs |
number |
<optional> |
0 |
- Source:
Returns:
- Type
- boolean
isMac() → {boolean}
Determine if the current platform is macOS.
- Source:
Returns:
- Type
- boolean
isMouseInside(x, y, w, h, offsopt) → {boolean}
Test if the mouse is inside a rectangle.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number | |||
y |
number | |||
w |
number | |||
h |
number | |||
offs |
number |
<optional> |
0 |
- Source:
Returns:
- Type
- boolean
isPointInTriangle(pt, v1, v2, v3) → {boolean}
Check if a point lies inside the triangle defined by v1,v2,v3.
Parameters:
Name | Type | Description |
---|---|---|
pt |
Vec2D | |
v1 |
Vec2D | |
v2 |
Vec2D | |
v3 |
Vec2D |
- Source:
Returns:
- Type
- boolean
lerpColorOKLab(col1, col2, t) → {p5.Color}
Interpolate between two colours using the OKLab colour space.
Parameters:
Name | Type | Description |
---|---|---|
col1 |
p5.Color | |
col2 |
p5.Color | |
t |
number | Interpolation factor [0,1] |
- Source:
Returns:
- Type
- p5.Color
lum(col) → {number}
Calculate the luminance of a colour.
Parameters:
Name | Type | Description |
---|---|---|
col |
p5.Color | Array.<number> |
- Source:
Returns:
- Type
- number
midPoint(va, vb) → {Vec2D|Vec3D}
Midpoint between two vectors.
Parameters:
Name | Type | Description |
---|---|---|
va |
Vec2D | Vec3D | |
vb |
Vec2D | Vec3D |
- Source:
Returns:
- Type
- Vec2D | Vec3D
mix(va, vb, t) → {Vec2D|Vec3D}
Linear interpolation between two vectors.
Parameters:
Name | Type | Description |
---|---|---|
va |
Vec2D | Vec3D | |
vb |
Vec2D | Vec3D | |
t |
number |
- Source:
Returns:
- Type
- Vec2D | Vec3D
nmc(x) → {number}
Normalised cosine mapping in range [0,1].
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
numsToRoundedPercentages(list) → {Array.<number>}
Convert an array of numbers to rounded percentages that sum to 100.
Parameters:
Name | Type | Description |
---|---|---|
list |
Array.<number> |
- Source:
Returns:
- Type
- Array.<number>
paramToIntSteps(t, n) → {number}
Convert a parameter t in [0,1] into an integer range [0,n).
Parameters:
Name | Type | Description |
---|---|---|
t |
number | |
n |
number |
- Source:
Returns:
- Type
- number
pushpop(…args)
Execute a drawing function wrapped in push/pop calls. Can also operate on a p5.Graphics instance if provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
any |
<repeatable> |
Either (pg, fn) or (fn). |
- Source:
randCol() → {p5.Color}
Generate a random RGB colour.
- Source:
Returns:
- Type
- p5.Color
randomDate(date1, date2) → {Date}
Generate a random Date between two dates.
Parameters:
Name | Type | Description |
---|---|---|
date1 |
string | Date | |
date2 |
string | Date |
- Source:
Returns:
- Type
- Date
randomGaussianBoxMueller2(muopt, sigmaopt) → {Vec2D}
Generate a 2D vector with normally distributed components using the Box–Muller method.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
mu |
Vec2D |
<optional> |
new Vec2D() | Mean vector |
sigma |
number |
<optional> |
1 | Standard deviation |
- Source:
Returns:
- Type
- Vec2D
restoreSerializedP5Color(obj) → {p5.Color|object}
Convert a serialised p5.Color back into a live p5.Color instance.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | Serialised colour object. |
- Source:
Returns:
- Type
- p5.Color | object
restoreSerializedVec2D(obj) → {Vec2D|object}
Convert a plain object to a Vec2D if it contains x and y.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | Potentially serialised vector. |
- Source:
Returns:
- Type
- Vec2D | object
restoreSerializedVec3D(obj) → {Vec3D|object}
Convert a plain object to a Vec3D if it contains x, y, and z.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | Potentially serialised vector. |
- Source:
Returns:
- Type
- Vec3D | object
setDuration(_duration)
Configure the animation duration in seconds.
Parameters:
Name | Type | Description |
---|---|---|
_duration |
number |
- Source:
setTime()
Update global time and progress variables.
- Source:
sigmoid(x) → {number}
Sigmoid curve.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
sign(x) → {number}
Returns the sign of a number as -1 or 1.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
signedAngleBetween(v, w) → {number}
Signed angle from vector v to vector w.
Parameters:
Name | Type | Description |
---|---|---|
v |
Vec2D | |
w |
Vec2D |
- Source:
Returns:
- Type
- number
signedAngleDiff(angle, anchorAngle) → {number}
Calculate signed difference between two angles.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | |
anchorAngle |
number |
- Source:
Returns:
- Type
- number
simpleIntToFloatHash(i) → {number}
Simple deterministic hash from an integer to a float in [0,1].
Parameters:
Name | Type | Description |
---|---|---|
i |
number |
- Source:
Returns:
- Type
- number
simplifyAngle(angle) → {number}
Wrap any angle to the range [0,TAU).
Parameters:
Name | Type | Description |
---|---|---|
angle |
number |
- Source:
Returns:
- Type
- number
stringToFloatHash(inputString) → {number}
Hash a string to a float in [0,1].
Parameters:
Name | Type | Description |
---|---|---|
inputString |
string |
- Source:
Returns:
- Type
- number
tanh(x) → {number}
Hyperbolic tangent implemented via sigmoid.
Parameters:
Name | Type | Description |
---|---|---|
x |
number |
- Source:
Returns:
- Type
- number
toB64(n) → {string}
Convert a number to a base64-like string.
Parameters:
Name | Type | Description |
---|---|---|
n |
number |
- Source:
Returns:
- Type
- string
toxiBezierVertex(cp1, cp2, p2)
p5 wrapper for toxiclibs bezier vertex convenience.
Parameters:
Name | Type | Description |
---|---|---|
cp1 |
Vec2D | Control point 1 |
cp2 |
Vec2D | Control point 2 |
p2 |
Vec2D | End point |
- Source:
toxiFillet(filletStart, filletEnd, cen)
Draw a bezier fillet between two points around a centre.
Parameters:
Name | Type | Description |
---|---|---|
filletStart |
Vec2D | |
filletEnd |
Vec2D | |
cen |
Vec2D | Centre of the fillet. |
- Source:
toxiVertex(v)
p5 vertex wrapper using a Vec2D.
Parameters:
Name | Type | Description |
---|---|---|
v |
Vec2D |
- Source:
triangleSign()
Helper sign used in isPointInTriangle.
- Source:
vectorComponents(v) → {Array.<number>}
Convert a vector into an array of its numeric components.
Parameters:
Name | Type | Description |
---|---|---|
v |
Vec2D | Vec3D |
- Source:
Returns:
- Type
- Array.<number>