forked from ingibjorgf/ANotWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
238 lines (202 loc) · 7.31 KB
/
main.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//Imaginary center line where the other lines move up and down from
//They all begin at the center line, same size, same distance from each other
//The other lines are 6
//The move up and down and to each other, vertical and horiz
//Then there will be horiz lines and triangles which they will move towards
//bounce back and forth from
//Make 6 lines in the middle, equal distance from each other
//Make the lines move toward each other
//Make the lines bigger and smaller
//Make the lines go up and down
//Small horizontal lines appear
//Make vertical lines move towards horizontal lines, up and down
//Make triangles, same
my_interface = (function() {
var leftMeet = 0.425;
var leftXMid = 0.35;
var leftXExpandFinal = [leftXMid, 0.4 - 0.15, leftXMid, 0.6 + 0.15];
var leftLarge = [0.325, 0.4 - 0.05, 0.325, 0.6 + 0.05]
var twoLineMeet = [leftMeet, 0.45, leftMeet, 0.55];
var rightXExpandFinal = [0.5 + 0.15, 0.4 - 0.15, 0.5 + 0.15, 0.6 + 0.15];
var rightXExpandFinal2 = [0.5 + 0.25, 0.4 - 0.15, 0.5 + 0.25, 0.6 + 0.15];
var rightXExpandFinal3 = [0.5 + 0.25, 0.475, 0.5 + 0.25, 0.525];
var topHorBord = 0.05;
var botHorBord = 0.95;
var rightExpandLine = new Anim.Line(
[0.5, 0.4, 0.5, 0.6], rightXExpandFinal,
20000,
true
);
var centExpandAnim = new Anim.Simul(
[new Anim.Line(
[0.5, 0.4, 0.5, 0.6], leftXExpandFinal,
20000,
true
),
rightExpandLine
],
null,
true
)
var centExpandAnim2 = new Anim.Simul(
[new Anim.Line(
[0.5, 0.4, 0.5, 0.6], [0.5 - 0.3, 0.4 - 0.3, 0.5 - 0.3, 0.6 + 0.3],
40000, //hraði vinstri lína
true
),
new Anim.Line(
[0.5, 0.4, 0.5, 0.6], [0.5 + 0.3, 0.4 - 0.3, 0.5 + 0.3, 0.6 + 0.3],
40000, //hraði hægri lína
true
)
],
null,
true
)
var covExpandAnim = new Anim.Simul(
[new Anim.Line(
[leftXMid, topHorBord, leftXMid, topHorBord], [leftXMid - 0.03, topHorBord, leftXMid + 0.03, topHorBord],
1000,
true
),
new Anim.Line(
[0.65, topHorBord, 0.65, topHorBord], [0.65 - 0.03, topHorBord, 0.65 + 0.03, topHorBord],
1000,
true
),
new Anim.Line(
[leftXMid, botHorBord, leftXMid, botHorBord], [leftXMid - 0.03, botHorBord, leftXMid + 0.03, botHorBord],
1000,
true
),
new Anim.Line(
[0.65, botHorBord, 0.65, botHorBord], [0.65 - 0.03, botHorBord, 0.65 + 0.03, botHorBord],
1000,
true
),
],
null,
true
)
var outwards = new Anim.Consec([
centExpandAnim,
// centExpandAnim2,
// covExpandAnim,
], null, false)
var smallSlideUp = new Anim.Line([leftXMid, botHorBord-0.1, leftXMid, botHorBord], [leftXMid, topHorBord, leftXMid, topHorBord+0.1], 5000, false);
var leftLine = new Anim.Consec([
new Anim.Line(leftXExpandFinal, [leftXMid, 0.45, leftXMid, 0.55], 20000, false).then(
[leftXMid, 0.45, leftXMid, 0.55], 5000, false).then(
twoLineMeet, 10000, false).then(
twoLineMeet, 10000, false).then(
leftLarge, 3000, false).then(
twoLineMeet, 3000, false).then(
leftLarge, 3000, false).then(
twoLineMeet, 3000, false).then(
leftLarge, 3000, false).then(
twoLineMeet, 3000, false).then(
leftLarge, 3000, false).then(
twoLineMeet, 3000, false).then(
leftLarge, 3000, false).then(
twoLineMeet, 3000, false)
// new Anim.Line([leftXMid, 0.45, leftXMid, 0.55], [leftXMid, botHorBord-0.1, leftXMid, botHorBord], 2500, false),
// new Anim.Repeat(new Anim.Consec([ smallSlideUp, new Anim.Reverse(smallSlideUp)]), 10)
], null, true)
var rightLine = new Anim.Consec([
new Anim.Line(rightXExpandFinal, rightXExpandFinal, 15000, false).then(
rightXExpandFinal2, 10000, false).then(
rightXExpandFinal2, 10000, false).then(
rightXExpandFinal3, 30000, true)
], null, true)
var slide = new Anim.Simul([
// new Anim.Final(covExpandAnim, null, true),
// new Anim.Final(centExpandAnim2, null, true),
leftLine,
rightLine
], null, true)
var centerLine = new Anim.Line([0.5, 0.4, 0.5, 0.6], [0.5, 0.4, 0.5, 0.6], 45000, true).then(
[0.5, 0.45, 0.5, 0.55], 10000, false
).then(
twoLineMeet, 10000, true
);
var main = new Anim.Consec([
new Anim.Wait(10000),
outwards,
slide,
], null, true)
var root = new Anim.Simul(
[main, centerLine]
)
var speed = 10
root = new Anim.Speed(root, speed);
var main = function() {
console.log("running main"); //skrifar i console
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var state = {
lines: []
}
var lastState = {
lines: []
}
var skip = 0 / speed;
var startTime = new Date();
function initialize() {
window.addEventListener('resize', resizeCanvas, false);
resizeCanvas();
setInterval(redraw, 20);
setInterval(update, 20);
}
function update() {
var currentTime = new Date();
var sinceStart = currentTime - startTime + skip;
state = root.get(sinceStart);
}
function redraw(force) {
var needsRedraw = false
if (state.lines.length !== lastState.lines.length) {
needsRedraw = true;
} else {
for (var i = 0; i < state.lines.length; i++) {
for (var j = 0; j < 4; j++) {
if (state.lines[i][j] !== lastState.lines[i][j]) {
needsRedraw = true;
}
}
}
}
if (!(needsRedraw || force)) {
return
}
console.log("redraw");
width = canvas.width;
height = canvas.height;
context.fillStyle = "#444249";
context.fillRect(0, 0, width, height);
state.lines.forEach(function(line, i) {
context.beginPath();
context.moveTo(width * line[0], height * line[1]);
context.lineTo(width * line[2], height * line[3]);
context.strokeStyle = "#ffffff";
context.lineWidth = 3;
context.stroke();
});
lastState = state;
}
// Runs each time the DOM window resize event fires.
// Resets the canvas dimensions to match window,
// then draws the new borders accordingly.
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
redraw(true);
}
initialize();
};
main();
return {
hello: function() {
console.log("hello world");
}
}
})();