-
Notifications
You must be signed in to change notification settings - Fork 1
/
function-list.js
208 lines (208 loc) · 5.2 KB
/
function-list.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
function glslAxis(perspective = "1.0") {
if (perspective === "x") {
return "st.x";
} else if (perspective === "y") {
return "st.y";
} else if (perspective === "2x") {
return "st.x*2.0";
} else if (perspective === "x/2") {
return "st.x/2.0";
} else if (perspective === "pow(x,2)") {
return "pow(st.x,2.0)";
} else if (perspective === "x+y") {
return "st.x+st.y";
} else if (perspective === "x-y") {
return "st.x-st.y";
} else if (perspective === "x*y") {
return "st.x*st.y";
} else if (perspective === "x/y") {
return "st.x/st.y";
} else if (perspective === "y-x") {
return "st.y-st.x";
} else if (perspective === "y/x") {
return "st.y/st.x";
} else if (perspective === "2y") {
return "st.y*2.0";
} else if (perspective === "y/2") {
return "st.y/2.0";
} else if (perspective === "pow(y,2)") {
return "pow(st.y,2.0)";
} else {
return perspective;
}
}
function flash(fast0 = 1, fast1 = 1, fast2 = 0.01) {
return solid(glslAxis("x"), glslAxis("y"), () => time * fast0)
.diff(gradient(fast1))
.colorama(fast2);
}
function list(s = 0, t = 1) {
let sin = () => Math.sin(time * t);
let cos = () => Math.cos(time * t);
let tan = () => Math.tan(time * t);
let asin = () => Math.asin(time * t);
let acos = () => Math.acos(time * t);
let atan = () => Math.atan(time * t);
const ar = [sin(), cos(), tan(), asin(), acos(), atan()];
return ar[s];
}
function easeInOut(k = 0) {
const linear = "linear";
const sine = "sine";
const easeInOut = "easeInOut";
const easeInOutHalf = "easeInOutHalf";
const easeInOutQuad = "easeInOutQuad";
const easeInOutCubic = "easeInOutCubic";
const easeInOutQuart = "easeInOutQuart";
const easeInOutQuint = "easeInOutQuint";
const easeInOutExpo = "easeInOutExpo";
const easeInOutCirc = "easeInOutCirc";
const easeInOutBack = "easeInOutBack";
const easeInOutElastic = "easeInOutElastic";
const easeInOutBounce = "easeInOutBounce";
const array = [
linear,
sine,
easeInOut,
easeInOutHalf,
easeInOutQuad,
easeInOutCubic,
easeInOutQuart,
easeInOutQuint,
easeInOutExpo,
easeInOutCirc,
easeInOutBack,
easeInOutElastic,
easeInOutBounce,
];
return array[k];
}
function varDef(func2 = "hydra", func3 = Math.sin, v = 10) {
func2 = [...Array(v).keys()];
for (let u = 0; u <= v; u++) {
func2[v] = func3(v);
}
return func2[v];
}
function funcAry(
init = 0,
r = 0.5,
term = 1,
step0 = 0.01,
step1 = 0.1,
func0 = Math.sin,
func1 = Math.cos
) {
let ary = [];
for (let i = init; i <= r; i += step0) {
ary.push(func0(i));
}
for (let j = r; j <= term; j += step1) {
ary.push(func1(j));
}
return ary;
}
function randAry(m = 100, mag = 0.01) {
let ay = [];
for (let l = 0; l <= m; l++) {
ay.push(l);
}
return ay[Math.floor(Math.random() * ay.length)] * mag;
}
function genAry(m = 100, mag = 0.01, rep = 10) {
let xy = [];
for (let z = 0; z <= rep; z++) {
xy.push(randAry(m, mag));
}
return xy;
}
function setLoop(speed0 = 1, speed1 = 1, speed2 = 1, speed3 = 1, ms = 1000) {
let count = 0;
let sf = [speed0, speed1, speed2, speed3];
let o = [o0, o1, o2, o3];
const countUp = () => {
count++;
};
const intervalId = setInterval(() => {
countUp();
for (let i = 0; i < o.length; i++) {
if (count % o.length == i) {
speed = sf[i];
render(o[i]);
}
}
}, ms);
}
function pad(
amount = 10,
output = o0,
form = 4,
inside = 0,
outside = 1,
breath = 0.99
) {
return solid().diff(
src(output)
.pixelate(amount, amount)
.mult(shape(form, inside, outside).repeat(amount, amount).invert())
.diff(
src(output)
.scale(breath)
.diff(src(output).scale(2 - breath))
)
);
}
function particle(output = o0, breath = 0.99) {
return solid().diff(
src(output)
.scale(breath)
.diff(src(output).scale(2 - breath))
);
}
function rgba(output = o0, red = 0, green = 0, blue = 0, alpha = 1) {
return src(output).r(red).g(green).b(blue).a(alpha);
}
function hsb(output = o0, hue = 0.5, saturation = 0.5, bright = 0.5) {
return src(output).hue(hue).saturate(saturation).brightness(bright);
}
function zebra(
video = src(o0),
timesY = 1,
timesX = 1,
func4 = Math.sin,
speed4 = 0.1
) {
synth = () => video;
return synth().modulateRepeatY(shape(2).repeatY(timesY), timesX, () =>
func4(time * speed4)
);
}
function form(n=4, k=2,n0=0,n1=1,o=60,p=1/8,q=300) {
if (n % 2 === 1) {
return osc(o,p,q)
.kaleid(n)
.rotate(Math.PI / 2)
.mult(shape(n,n0,n1));
} else if (n % Math.pow(2, k) === 0) {
return osc(o,p,q)
.kaleid(Math.pow(2, k))
.rotate(Math.PI / Math.pow(2, k))
.mult(shape(Math.pow(2, k)));
} else if (n % 2 === 0) {
return osc()
.kaleid(n)
.rotate(Math.PI)
.mult(shape(n,n0,n1));
}
}
function rainbow(spectrum=0) {
red = () => solid(1, 0, 0);
orange = () => solid(1, 0.5, 0);
yellow = () => solid(1, 1, 0);
green = () => solid(0, 1, 0);
blue = () => solid(0, 0, 1);
indigo = () => solid(75 / 255, 0, 130 / 255);
violet = () => solid(238 / 255, 130 / 255, 238 / 255);
let filter = [red(), orange(), yellow(), green(), blue(), indigo(), violet()];
return filter[spectrum];
}