forked from ascr-ecx/colormoves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utility.js
42 lines (38 loc) · 793 Bytes
/
Utility.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var PI = 3.141592654
function makeArray(d1, d2, d3) {
var arr = [];
if(d3)
{
for(i = 0; i < d1; i++)
{
arr.push([]);
for(j = 0; j < d2; j++)
arr[i].push(new Array(d3));
}
}
else
{
for(i = 0; i < d1; i++)
arr.push(new Array(d2));
}
return arr;
}
function deepCopyArray(array, dimensions)
{
var newarray = array.slice();
if(--dimensions)
for(var i = 0; i < array.length; i++)
newarray[i] = deepCopyArray(array[i], dimensions);
return newarray;
}
function isFunction(x) {
return Object.prototype.toString.call(x) == "[object Function]";
}
function isArray(x) {
return Object.prototype.toString.call(x) == "[object Array]";
}
function vecLerp(vout, v0, v1, alpha)
{
for(var i = 0; i < v0.length; i++)
vout[i] = v0[i] * (1.0 - alpha) + v1[i] * alpha;
}