-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.pde
More file actions
156 lines (127 loc) · 4.91 KB
/
Example.pde
File metadata and controls
156 lines (127 loc) · 4.91 KB
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
int maxExampleCount;
class Example extends Element {
int indexI, indexJ;
float posX, posY;
float opacity;
float initialPosX, initialPosY, initialW, initialH;
float initialOpacity;
boolean hoverExample;
boolean rowHovered, rowSelected;
int tempState;
Example(int m, int n) {
tempState = 0;
indexI = m;
indexJ = n;
//currentLessonPosition = position.x;
paddingLeft = 20;
paddingRight = 20;
paddingTop = 20;
paddingBottom = 20;
h = (effectiveHeight/lessonCount) - paddingTop - paddingBottom;
w = h;
position = new PVector(marginLeft + paddingLeft + sidebarWidth[globalState] + mainWidth[globalState] + (indexJ * secondaryWidth[globalState]/4.0), marginTop + paddingTop + 1.0 * indexI * effectiveHeight/lessonCount);
posX = position.x;
posY = position.y;
mainColor = lGrey;
hoverColor = cyan;
clickedColor = cyan;
opacity = 255;
hoverExample = false;
initialPosX = position.x;
initialPosY = position.y;
initialW = w;
initialH = h;
initialOpacity = 255;
}
void transitionSort() {
float delay = indexJ * 0.2;
Ani.to(this, 0.6, delay, "w", (effectiveHeight/lessonCount) - paddingTop - paddingBottom, Ani.QUAD_IN);
Ani.to(this, 0.6, delay, "h", (effectiveHeight/lessonCount) - paddingTop - paddingBottom, Ani.QUAD_IN);
Ani.to(this, 1, delay, "posX", marginLeft + paddingLeft + sidebarWidth[0] + mainWidth[0] + (3 * secondaryWidth[0]/4.0), Ani.SINE_IN_OUT);
Ani.to(this, 1.4, delay, "posY", marginTop + paddingTop + indexJ * (effectiveHeight/lessonCount), Ani.QUAD_IN_OUT);
Ani.to(this, 0.6, delay, "opacity", 255, Ani.QUAD_IN);
}
void transitionOut() {
float delay = indexJ * 0.1;
Ani.to(this, 0.6, delay, "w", 0, Ani.QUAD_IN);
Ani.to(this, 0.6, delay, "h", 0, Ani.QUAD_IN);
Ani.to(this, 1, delay, "posX", width+ 5*w, Ani.QUAD_IN);
Ani.to(this, 1.4, delay, "posY", -5*marginTop + indexJ * (effectiveHeight/lessonCount), Ani.EXPO_IN);
Ani.to(this, 0.6, delay, "opacity", 0, Ani.QUAD_IN);
}
void onStateChange(int state) {
println("hi there");
float delay = indexJ * 0.1;
switch(state) {
case 0:
Ani.to(this, 0.6, delay, "w", initialW, Ani.QUAD_OUT);
Ani.to(this, 0.6, delay, "h", initialH, Ani.QUAD_OUT);
Ani.to(this, 1, delay, "posX", initialPosX, Ani.QUAD_OUT);
Ani.to(this, 1.4, delay, "posY", initialPosY, Ani.EXPO_OUT);
Ani.to(this, 0.6, delay, "opacity", initialOpacity, Ani.QUAD_OUT);
break;
case 1:
/*Ani.to(this, 0.6, delay, "w", 0, Ani.QUAD_IN);
Ani.to(this, 0.6, delay, "h", 0, Ani.QUAD_IN);
Ani.to(this, 1, delay, "posX", width+ 5*w, Ani.QUAD_IN);
Ani.to(this, 1.4, delay, "posY", -5*marginTop + indexJ * (effectiveHeight/lessonCount), Ani.EXPO_IN);
Ani.to(this, 0.6, delay, "opacity", 0, Ani.QUAD_IN);*/
break;
case 2:
/*Ani.to(this, 0.6, delay, "w", 0, Ani.QUAD_IN);
Ani.to(this, 0.6, delay, "h", 0, Ani.QUAD_IN);
Ani.to(this, 1, delay, "posX", width+ 5*w, Ani.QUAD_IN);
Ani.to(this, 1.4, delay, "posY", -5*marginTop + indexJ * (effectiveHeight/lessonCount), Ani.EXPO_IN);
Ani.to(this, 0.6, delay, "opacity", 0, Ani.QUAD_IN);*/
break;
}
}
boolean checkRowHover() {
boolean temp = false;
for (int j=0; j<examples[indexI].length; j++) {
temp = temp || examples[indexI][j].hoverCheck;
}
temp = temp || lessons[indexI].hoverCheck;
return temp;
}
void onHover() {
super.onHover();
}
void onClick() { // call this from global click event - mouseClicked(){}
globalState = 2;
onGlobalStateChange(2);
super.onClick();
clickAnimation = new FillAnimation((float)mouseX, (float)mouseY, marginLeft+sidebarWidth[1] + 20, marginTop + 5, mainWidth[globalState], effectiveHeight - 10, clickedColor, 1);
}
void update() {
super.update();
rowHovered = checkRowHover();
position.x = posX;
position.y = posY;
if (globalState != tempState) {
onStateChange(globalState);
tempState = globalState;
}
}
void display() {
noStroke();
fill(mainColor, opacity);
if (rowHovered) {
strokeWeight(2);
stroke(hoverColor);
} else {
noStroke();
}
if (selectedCheck) {
fill(clickedColor);
}
if (hoverCheck) {
onHover();
strokeWeight(5);
stroke(hoverColor);
//fill(hoverColor);
} else {
rect(position, w, h);
}
}
}