Creative Code Toolkit
This library is my personal collection of helper functions in creative coding, revolving around modulation, array functions, random numbers, etc.
Functions
mapRange(v, a, b, c, d)
Map v in range [a, b] to range [c, d]
Param | Type |
---|
v | Number |
a | Number |
b | Number |
c | Number |
d | Number |
sinMap(v, div, a, b)
Map the output sin(v / div) to the range [a, b]
Param | Type |
---|
v | Number |
div | Number |
a | Number |
b | Number |
cosMap(v, div, a, b)
Map the output cos(v / div) to the range [a, b]
Param | Type |
---|
v | Number |
div | Number |
a | Number |
b | Number |
wrapValue(v, m, M)
if v is greater than M or less than m, wrap the value around to stay in this range
Param | Type |
---|
v | Number |
m | Number |
M | Number |
deepArrayCopy(a)
Return a deep copy array a
genArray(s)
Create an array of size s
get1dY(i, rowLength)
Get the Y component of a 1d array containing 2d data when the index is i
Param | Type |
---|
i | Number |
rowLength | Number |
get1dX(i, rowLength)
Get the X component of a 1d array containing 2d data when the index is i
Param | Type |
---|
i | Number |
rowLength | Number |
choose(a)
pick a random element from the array a
rndB(a, b)
Random number in range [a, b]
rndIntB(a, b)
Random integer in range [a, b]
polute()
Polutes the global scope with unnamespaced functions