// Random - Generate random number when pressing "N" key and display to canvas.
if ($.keys.down("r")) {
randomValue = $.math.random(0, 100);
}
$.text.print($.w/2,$.h/2, randomValue.toString());
$.math
Commonly used math methods such as floor, ceil, roundatan2, sin, cos using degrees. As well useful utility methods
Methods
- $.math.atan2(y,x,)//atan2 function that returns the result in degrees.
- $.math.sin(value,)//Sine of a value
- $.math.cos(value,)//Cosine of a value
- $.math.tan(value,)//Tangent of a value
- $.math.atan(value,)//Arctangent of a value
- $.math.floor(value,)//Rounds a number down to the nearest int.
- $.math.ceiling(value,)//Rounds a number up to the nearest int.
- $.math.round(value,)//Rounds a number to the nearest int.
- $.math.distance(xStart,yStart,xEnd,yEnd,)//Calculates distance between two points
- $.math.random(minVal,maxVal,)//Generates a random number between minVal and maxVal
- $.math.rescaleNumber(num,in_min,in_max,out_min,out_max,)//Rescales a number from one range to another