p5ex

An extension of p5.js. Including module: no-more-for-loops (Copyright 2018 FAL, licensed under MIT). GitHub repository: https://github.com/fal-works/p5ex
Version:
  • 0.5.6
Author:
License:
  • MIT
Source:

Classes

AlphaBackground
AngleQuantity
CircularArc
CleanableArray
CleanableSpriteArray
DrawableArray
Drawer
DrawerBuilder
FontManager
FontUnit
FrameCounter
Grid
Illuminant
KinematicQuantity
LineSegment
LoopableArray
LoopedFrameCounter
NaiveCell
NaiveEdge
NonLoopedFrameCounter
NullCell
NumberContainer
ObjectPool
p5exClass
PhysicsBody
PoolableArray
QuadraticBezierCurve
RandomShapeColor
RectangleRegion
Region
ScalableCanvas
ScalableShape
ScaleFactor
ScreenEffect
ScreenFlash
ScreenShake
ShapeColor
ShapeType
SpriteArray
SteppableArray
TimedFrameCounter
TwoDimensionalArray
WeightedRandomSelector

Members

(inner, constant) Illuminants

Map of illuminants.
Source:

(inner, constant) keyDown

Holds a boolean value for each key which indicates if the key is currently down.
Source:

(inner, constant) ONE_AND_HALF_PI

1.5 * PI
Source:

(inner, constant) ScalableCanvasTypes

(To be filled) (This is not implemented as an enum because it is not supported by rollup)
Source:

(inner, constant) ShapeTypes

Set of shape types.
Source:

Methods

(inner) angleDifference(angleA, angleB)

Calculates the difference between two angles in range of -PI to PI.
Source:
Parameters:
Name Type Description
angleA the angle to subtract from
angleB the angle to subtract

(inner) applyRandomTexture(renderer, maxAlpha, blendopt, redopt, greenopt, blueopt)

Sets the specified color (default: black) to each pixel with a random alpha value.
Source:
Parameters:
Name Type Attributes Default Description
renderer Instance of either p5 or p5.Graphics.
maxAlpha number The max value of alpha channel (1 - 255).
blend boolean <optional>
true Set true for blending, false for replacing.
red number <optional>
0
green number <optional>
0
blue number <optional>
0

(inner) calculateLeverageForce(loadDirectionAngle, loadDistance, effortDistance, effortForceMagnitude, rotateClockwise, target)

Returns the 2D force vector which is to be applied to the load.
Source:
Parameters:
Name Type Description
loadDirectionAngle the direction angle from the fulcrum to the load
loadDistance the distance between the fulcrum and the load
effortDistance the distance between the fulcrum and the effort
effortForceMagnitude the effort force magnitude
rotateClockwise true if the load is to be rotated clockwise, otherwise false
target the vector to receive the result. Will be newly created if not specified

(inner) cielabColor(lValue, aValue, bValue, alphaValueopt)

Converts CIELAB values to an array of RGB values (0 - 255).
Source:
Parameters:
Name Type Attributes Description
lValue number L*: Lightness (0 - 100)
aValue number a* (0 - ca. 100)
bValue number b* (0 - ca. 100)
alphaValue number <optional>
Alhpa value (0 - 255)
Returns:
New Array of sRGB values.

(inner) cielabValueToXyzValue(cielabValue, illuminant, targetopt) → {Array.<number>}

Converts color values from CIELAB (D65) to XYZ.
Source:
Parameters:
Name Type Attributes Description
cielabValue Array.<number> Value array of L*, a*, b* (D65).
illuminant Illuminant Instance of Illuminant.
target Array.<number> <optional>
Target array for receiving the result.
Returns:
Type:
Array.<number>
XYZ value array.

(inner) cielchColor(lValue, cValue, hValue, alphaValueopt)

Converts CIELCh values to an array of RGB values (0 - 255).
Source:
Parameters:
Name Type Attributes Description
lValue number L*: Lightness (0 - 100)
cValue number C*: Chroma (0 - ca. 100)
hValue number h*: Hue (0 - 2PI)
alphaValue number <optional>
Alhpa value (0 - 255)

(inner) distSq()

Calculates the squared value of the Euclidean distance between two points (considering a point as a vector object).
Source:

(inner) drawSineWave(p, drawingLength, peakToPeakAmplitude, waveLength)

Draws a sine wave.
Source:
Parameters:
Name Type Description
p
drawingLength
peakToPeakAmplitude
waveLength

(inner) easeLinear(ratio)

Linear easing function.
Source:
Parameters:
Name Type Description
ratio

(inner) easeOutBack(ratio)

easeOutBack.
Source:
Parameters:
Name Type Description
ratio

(inner) easeOutCubic(ratio)

easeOutCubic.
Source:
Parameters:
Name Type Description
ratio

(inner) easeOutQuad(ratio)

easeOutQuad.
Source:
Parameters:
Name Type Description
ratio

(inner) easeOutQuart(ratio)

easeOutQuart.
Source:
Parameters:
Name Type Description
ratio

(inner) EMPTY_FUNCTION()

An empty function.
Source:

(inner) getDirectionAngle(referencePosition, targetPosition)

Calculates the direction angle from one vector to another.
Source:
Parameters:
Name Type Description
referencePosition
targetPosition

(inner) getEasingFunction(exponent)

Returns an easeOut function.
Source:
Parameters:
Name Type Description
exponent Integer from 1 to 4.

(inner) getRandom(array)

Returns one of array elements randomly.
Source:
Parameters:
Name Type Description
array

(inner) gradationBackground(p, backgroundColor, fromColor, toColor, lerpRatioExponent)

Fill the canvas or graphics (according to p.currentRenderer) with gradation.
Source:
Parameters:
Name Type Default Description
p
backgroundColor
fromColor
toColor
lerpRatioExponent 1

(inner) hsbColor(h, s, b, aopt)

Creates a new p5.Color instance in HSB color mode and immediately reset the color mode to default.
Source:
Parameters:
Name Type Attributes Description
h number Hue (0 - 360)
s number Saturation (0 - 100)
b number Brightness (0 - 100)
a number <optional>
Alpha (0 - 255)

(inner) lerp(startValue, endValue, ratio)

Just lerp.
Source:
Parameters:
Name Type Description
startValue The start value.
endValue The end value.
ratio The ratio between 0 and 1.

(inner) lerpPixel(renderer, x, y, red, green, blue, pixelDensity, lerpRatio)

Lerp color to the specified pixel. The alpha channel remains unchanged. Should be used in conjunction with loadPixels() and updatePixels().
Source:
Parameters:
Name Type Default Description
renderer Instance of either p5 or p5.Graphics.
x The x index of the pixel.
y The y index of the pixel.
red The red value (0 - 255).
green The green value (0 - 255).
blue The blue value (0 - 255).
pixelDensity If not specified, renderer.pixelDensity() will be called.
lerpRatio 1 The lerp ratio (0 - 1). If 1, the color will be replaced.

(inner) listenKey()

Begins to listen key events. Default behaviors for arrow keys will be prevented.
Source:

(inner) loopArray(array, callback)

Executes a provided function once for each array element.
Source:
Parameters:
Name Type Description
array Array
callback loopArrayCallBack

(inner) loopArrayBackwards(array, callback)

Executes a provided function once for each array element in descending order.
Source:
Parameters:
Name Type Description
array Array
callback loopArrayCallback

(inner) mouseIsInCanvas(p)

Returns true if the mouse is within the canvas.
Source:
Parameters:
Name Type Description
p The p5 instance.

(inner) mouseOnCanvas(p)

Returns true if the mouse cursor is on the canvas.
Source:
Parameters:
Name Type Description
p p5ex instance.

(inner) multiplyMatrixAndArray(matrix, array, targetopt)

Multiplies the given matrix and array. The number of matrix columns and the array length must be identical.
Source:
Parameters:
Name Type Attributes Description
matrix Array.<Array.<number>> Any matrix.
array Array.<number> Any one-dimensional array of numbers.
target Array.<number> <optional>
Target array for receiving the result.
Returns:
Product of the given values as an array.

(inner) nestedLoopJoin(array, otherArray, callback)

Joins two arrays and executes a provided function once for each joined pair.
Source:
Parameters:
Name Type Description
array Array
otherArray Array
callback nestedLoopJoinCallBack

(inner) popRandom(array)

Returns and removes one array element randomly.
Source:
Parameters:
Name Type Description
array

(inner) randomBetween()

Returns random value from the min number up to (but not including) the max number.
Source:

(inner) randomInt()

Returns random integer from 0 up to (but not including) the max number.
Source:

(inner) randomIntBetween()

Returns random integer from the min number up to (but not including) the max number.
Source:

(inner) randomSign(n)

Returns n or -n randomly. (n = provided number)
Source:
Parameters:
Name Type Description
n number any number

(inner) roundRobin(array, callback)

Executes a provided function once for each pair within the array.
Source:
Parameters:
Name Type Description
array Array
callback roundRobinCallBack

(inner) setIlluminant(illuminant)

Sets the current illuminant. (e.g. D50, D65 etc.)
Source:
Parameters:
Name Type Description
illuminant Any Illuminant.
Example
setIlluminant(Illuminants.D65);

(inner) setPixel(renderer, x, y, red, green, blue, pixelDensity)

Set color to the specified pixel. Should be used in conjunction with loadPixels() and updatePixels().
Source:
Parameters:
Name Type Description
renderer Instance of either p5 or p5.Graphics.
x The x index of the pixel.
y The y index of the pixel.
red The red value (0 - 255).
green The green value (0 - 255).
blue The blue value (0 - 255).
pixelDensity If not specified, renderer.pixelDensity() will be called.

(inner) subtractColor(c1, c2, alphaValueopt)

Returns the difference of two colors. The alpha values of the original colors will be ignored.
Source:
Parameters:
Name Type Attributes Description
c1 p5.Color The color to subtract from
c2 p5.Color The color to subtract
alphaValue number <optional>
Alpha value of the result color

Type Definitions

elementPairCallBack(element, otherElement)

Source:
Parameters:
Name Type Description
element
otherElement

loopArrayCallBack(currentValue, indexopt, arrayopt)

Source:
Parameters:
Name Type Attributes Description
currentValue
index number <optional>
array Array <optional>

loopArrayCallBack(currentValue, indexopt, arrayopt)

Source:
Parameters:
Name Type Attributes Description
currentValue
index number <optional>
array Array <optional>

nestedLoopJoinCallBack(element, otherElement)

Source:
Parameters:
Name Type Description
element
otherElement

roundRobinCallBack(element, otherElement)

Source:
Parameters:
Name Type Description
element
otherElement