-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhotoBrowse.pde
125 lines (105 loc) · 3.16 KB
/
PhotoBrowse.pde
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
// ------------PhotoBrowse ----------------
String[] pb_names = {"00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg", "05.jpg", "06.jpg", "07.jpg", "08.jpg", "09.jpg", "10.jpg"};
PImage pb_imgShadow;
Tile[] pb_tiles;
int pb_selectedTile;
float pb_ANI_TIME = 0.5;
float pb_WIDTH = 112.5;
float pb_HEIGHT = 62.5;
void pb_init(Table config){
size(1400, 800, OPENGL);
background(0);
pb_selectedTile = 0;
pb_imgShadow = loadImage("pb_shadow.png");
smooth();
noStroke();
Ani.init(this);
pb_names = split(config.findRow("names", 1).getString(2), ",");
// Init Tiles
pb_tiles = new Tile[pb_names.length];
TableRow tr = null;
for (int i=0; i<pb_tiles.length; i++){
pb_tiles[i] = new Tile(pb_names[i]);
tr = config.findRow(pb_tiles[i].fn, 1);
pb_tiles[i].label = tr.getString(2);
pb_tiles[i].description = tr.getString(3);
}
pb_initTiles();
}
void pb_draw(){
background(0);
image(pb_tiles[pb_selectedTile].img, 0.25*width, 0, 0.75 * width, 0.75 * height);
pb_imgShadow.resize(int(0.75*width), int(0.75*height));
image(pb_imgShadow, 0.25*width, 0, 0.75 * width, 0.75 * height);
textFont(FONT, 32);
fill(231, 231, 231);
text(pb_tiles[pb_selectedTile].label, 0.07*width, 0.07*height);
textSize(16);
fill(170, 170, 170);
text(pb_tiles[pb_selectedTile].description, 0.07*width, 0.14*height);
pushMatrix();
translate(0.1 * width, 0.8 * height);
for (int i=0; i<pb_tiles.length; i++){
pb_tiles[i].selected = false;
}
pb_tiles[pb_selectedTile].selected = true;
for (int i=0; i<pb_tiles.length; i++){
pb_tiles[i].drawTile();
}
popMatrix();
}
void pb_keyPressed(){
if ((key == DELETE) || (key == BACKSPACE)){
pb_back();
}
if (key == CODED){
if (keyCode == RIGHT){
pb_right();
}else if (keyCode == LEFT){
pb_left();
}
}
}
public void pb_initTiles(){
pb_tiles[0].position.set(0.0 - 0.0, 0.0, 0.0);
pb_tiles[0].rotationY = 0.0;
for (int i=1; i<pb_tiles.length; i++ ) {
pb_tiles[i].position.set(((pb_WIDTH * 2) + 10) * i, 0.0, 0.0);
}
}
public void pb_moveTiles() {
// left covers
for (int i=0; i<pb_selectedTile; i++ ) {
Ani.to(pb_tiles[i].position, pb_ANI_TIME, "x", - ((2 * pb_WIDTH) + 10)*(pb_selectedTile-i), Ani.CIRC_OUT);
Ani.to(pb_tiles[i].position, pb_ANI_TIME, "y", 0.0, Ani.CIRC_OUT);
Ani.to(pb_tiles[i].position, pb_ANI_TIME, "z", 0.0, Ani.CIRC_OUT);
}
// central cover
Ani.to(pb_tiles[pb_selectedTile].position, 0.5, "x", 0.0, Ani.CIRC_OUT);
Ani.to(pb_tiles[pb_selectedTile].position, pb_ANI_TIME, "y", 0.0, Ani.CIRC_OUT);
// right covers
for (int i=pb_selectedTile + 1; i<pb_tiles.length; i++ ) {
Ani.to(pb_tiles[i].position, pb_ANI_TIME, "x", ((2 * pb_WIDTH) + 10)*(i-pb_selectedTile), Ani.CIRC_OUT);
Ani.to(pb_tiles[i].position, pb_ANI_TIME, "y", 0.0, Ani.CIRC_OUT);
}
}
void pb_right(){
pb_selectedTile++;
if (pb_selectedTile == pb_names.length){
pb_selectedTile--;
}
pb_moveTiles();
}
void pb_left(){
pb_selectedTile--;
if (pb_selectedTile < 0){
pb_selectedTile++;
}
pb_moveTiles();
}
void pb_pause(){
// The pause method is only called when the screensaver is activated.
}
void pb_back(){
switchBack();
}