randomSeed(seed);
Set a random seed.
Arguments
seed
The seed valueReturns
number
The random valuerandom();
Get a random number.
random(max);
Arguments
max
The maximum of the rangerandom() -- random number between 0 and 1
random(3) -- random number between 0 and 3
random(min, max);
Arguments
min
The minimum of the rangemax
The maximum of the rangerandom(3, 12) -- random number between 3 and 12
random(arr);
Arguments
arr
The array to randomly select an item fromrandom({ 'A', 'B', 'C' }) -- random element in table
Returns
number
The random valueround(x);
Round a number to the nearest integer.
Arguments
x
The value to roundReturns
int
The rounded valuefloor(x);
floor is a function that takes in a number, and returns the greatest integer less or equal to x.
Arguments
x
The value to floorReturns
int
greatest integer less than or equals to xceil(x);
ceil is a function that takes in a number, and returns the smallest integer greater or equal to x.
Arguments
x
The value to floorReturns
int
The floored valuemin(a, b);
Return the smallest value.
Can also take any number of arguments, or a table.
Arguments
a
The first valueb
The second valueReturns
number
The smallest valuemin(6, 7); -- returns 6
min(6, 7, 4); -- returns 4
min({ 6, 7, 4 }); -- returns 4
max(a, b);
Return the largest value.
Can also take any number of arguments, or a table.
Arguments
a
The first valueb
The second valueReturns
number
The largest valuemax(2, 5); -- returns 5
max(2, 5, 7); -- returns 7
max({ 2, 5, 7 }); -- returns 7
abs(x);
Returns the absolute value of x.
Arguments
x
The input valueReturns
number
The absolote value of the inputmap(value, start, end, target_start, target_end);
Maps x from an original range to a target range.
Arguments
value
The value to mapstart
The start of the initial rangeend
The end of the initial rangetarget_start
The start of the target rangetarget_end
The end of the target rangeReturns
number
The mapped valuelocal mouseX_mapped = map(mouseX, 0, width, 0, 100);
-- mapped mouseX between 0 and 100
dist();
Calculates the distance between 2 points in 2D or 3D space.
dist(x1, y1, x2, y2);
Arguments
x1
The x coordinate of the first pointy1
The y coordinate of the first pointx2
The x coordinate of the second pointy2
The y coordinate of the second pointlocal d = dist(0, 0, 3, 4);
print(d) -- 5
dist(x1, y1, z1, x2, y2, z2);
Arguments
x1
The x coordinate of the first pointy1
The y coordinate of the first pointz1
The z coordinate of the first pointx2
The x coordinate of the second pointy2
The y coordinate of the second pointz2
The z coordinate of the second pointlocal d = dist(0, 0, 0, 2, 3, 6);
print(d) -- 7
dist(v1, v2);
Arguments
v1
The first vectorv2
The second vectorlocal a = createVector(-1, -1);
local b = createVector( 2, 3);
local d = dist(a, b);
print(d) -- 5
Returns
number
The distance between the pointsconstrain(x, min, max);
Limits x to a minimum and maximum value.
Arguments
x
The input valuemin
The minimum valuemax
The maximum valueReturns
number
The constrained valuesin(x);
Sine function (Trigonometry).
Arguments
x
The input valueReturns
number
The output valuecos(x);
Cosine function (Trigonometry).
Arguments
x
The input valueReturns
number
The output valuetan(x);
Tangent function (Trigonometry).
Arguments
x
The input valueReturns
number
The output value