-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
94 lines (80 loc) · 1.8 KB
/
functions.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//SIZE FUNCTIONS
//INPUT: (0,1)
//OUTPUT: pos real
const s_wideLeaf = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0, y: 10 };
p1 = { x: 1, y: 0 };
return quadBezier(p0, cp, p1, i).y;
};
const s_posBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0.3, y: 4 };
p1 = { x: 1, y: 0 };
return quadBezier(p0, cp, p1, i).y;
};
const s_leaveBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0.3, y: 4 };
p1 = { x: 1, y: 0 };
return quadBezier(p0, cp, p1, i).y;
};
const s_bigThenSmall = (i) => {
p0 = { x: 0, y: 0 };
cp1 = { x: 0.1, y: 20 };
cp2 = { x: 0.8, y: 2 };
p1 = { x: 1, y: 0 };
return cubicBezier(p0, cp1, cp2, p1, i).y;
};
const s_negBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0.8, y: 6 };
p1 = { x: 1, y: 0 };
return quadBezier(p0, cp, p1, i).y;
};
const sizef_arr = [
s_wideLeaf,
s_leaveBend,
s_posBend,
s_bigThenSmall,
s_negBend,
];
const getSizeF = () => {
return sizef_arr[Math.floor(Math.random() * sizef_arr.length)];
};
//INTERPOLATION FUNCTIONS
//INPUT: (0,1)
//OUTPUT: (0,1]
const p_linearRet = (i) => {
return i;
};
const p_posBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0.3, y: 1 };
p1 = { x: 1, y: 1 };
return quadBezier(p0, cp, p1, i).y;
};
const p_endBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0.6, y: 1 };
p1 = { x: 1, y: 1 };
o = quadBezier(p0, cp, p1, i).y;
if (o > 1) o = 1;
return o;
};
const p_negBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 1, y: 0 };
p1 = { x: 1, y: 1 };
return quadBezier(p0, cp, p1, i).y;
};
const p_leafBend = (i) => {
p0 = { x: 0, y: 0 };
cp = { x: 0, y: 1 };
p1 = { x: 1, y: 1 };
return quadBezier(p0, cp, p1, i).y;
};
const pointf_arr = [p_linearRet, p_posBend, p_endBend, p_negBend];
const getPointF = () => {
return pointf_arr[Math.floor(Math.random() * pointf_arr.length)];
};