-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
81 lines (71 loc) · 1.81 KB
/
index.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
let canvas;
let currentState = 1;
let animationHandler = -1;
let animationTime = 30;
let originalContainer;
function setup() {
canvas = createCanvas(windowWidth, windowHeight);
canvas.parent("sketch");
changePage(0);
background(255);
}
function drawBackObjects(State) {
let state = State;
if (state == 0) {
noStroke();
fill(200, 200, 200);
rect(0, 0, windowWidth, windowHeight);
fill(190, 0, 0);
rect(0, 0, windowWidth, windowHeight / 2);
}
if (state == 1) {
noStroke();
fill(200, 200, 200);
rect(0, 0, windowWidth, windowHeight);
fill(190, 0, 0);
rect(0, 0, windowWidth, 95);
}
if (state == 2) {
noStroke();
fill(200, 200, 200);
rect(0, 0, windowWidth, windowHeight);
fill(190, 0, 0);
rect(0, 0, windowWidth, windowHeight / 2 - (windowHeight / 2 - 95) / animationTime * (animationHandler + 1));
}
if (state == 3) {
noStroke();
fill(200, 200, 200);
rect(0, 0, windowWidth, windowHeight);
fill(190, 0, 0);
rect(0, 0, windowWidth, windowHeight);
}
if (state == 4) {
noStroke();
fill(200, 200, 200);
rect(0, 0, windowWidth, windowHeight);
fill(190, 0, 0);
rect(0, 0, windowWidth, 95 + (windowHeight - 95) / animationTime * (animationHandler + 1));
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
drawBackObjects(currentState);
}
function draw() {
if (animationHandler != -1 && currentState == 2) {
drawBackObjects(currentState);
animationHandler++;
if (animationHandler == animationTime) {
animationHandler = -1;
currentState = 1;
}
}
if (animationHandler != -1 && currentState == 4) {
drawBackObjects(currentState);
animationHandler++;
if (animationHandler == animationTime) {
animationHandler = -1;
currentState = 3;
}
}
}