-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexte_gramme3.pde
executable file
·168 lines (141 loc) · 4.11 KB
/
Texte_gramme3.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
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
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import processing.opengl.*;
import guicomponents.*;
PeasyCam cam;
PFont font;
PImage[] frames = new PImage[17];
int AlphaGeneral=80;
int DistanceGeneral=10;
//-
GTextField txf1;
GButton btn1;
GPanel pnl;
GHorzSlider sx,sy, sz;
int ax, ay, az;
// These are needed to remember PeasyCam offset and distance
float[] offsets = new float[3];
float[] rotations = new float[3];
double distance = 0.0f;
// Remember last slider values
// PeasyCam does not provide methods to set the absolute
// rotation angles, rotateX(ang) rotates about the X axis
// by ang radians
int lastSx, lastSy, lastSz;
int currSx, currSy, currSz;
// Used to remember PGraphics3D transformation matrix
PGraphics3D g3;
//
PImage a;
void setup(){
font = loadFont("ArialMT-20.vlw");
textFont(font, 20);
size(screen.width, screen.height, OPENGL );
frameRate(30);
smooth();
a = loadImage("images2/cover.jpg");
cam = new PeasyCam(this,1000);
//cam.pan(0,100000000);
// test image
for (int i = 0; i <9; i++) {
frames[i] = loadImage("images2/image"+i+".jpg");
}
for (int i = 1; i <9; i++) {
frames[i+8] = loadImage("images3/image"+i+".jpg");
println(i+8);
}
GComponent.globalColor = GCScheme.getColor(this, GCScheme.RED_SCHEME);
GComponent.globalFont = GFont.getFont(this, "Georgia", 12);
pnl = new GPanel(this, "Control alpha and distance", screen.width/100*5,screen.height/100*70,300,72);
sx = new GHorzSlider(this, 10, 8, 280, 16);
sx.setLimits(AlphaGeneral,0,250);
sx.setInertia(20);
sy = new GHorzSlider(this, 10, 28, 280, 16);
sy.setLimits(DistanceGeneral,1,300);
sy.setInertia(20);
pnl.add(sx);
pnl.add(sy);
g3 = (PGraphics3D)g;
}
void draw(){
if(pnl.isCollapsed()){
// Panel is collapsed
cam.setMouseControlled(!pnl.isDragging());
}
else {
// panel open must be using sliders
cam.setMouseControlled(false);
}
background( 0 );
translate((frames[0].width/4)/2*-1,(frames[0].height/4)/2*-1,0);
rotateY(TWO_PI/6);
htmlGramme2(frames);
Gui2D();
}
void htmlGramme2(PImage[] frame){
noStroke();
for (int i = frame.length-1; i >0; i--) {
//print(i);
PImage img = frame[i];
tint(250,250,250,AlphaGeneral);
beginShape();
texture(img);
vertex(0, 0,0, 0, 0);
vertex(img.width/5, 0 ,0, img.width, 0);
vertex(img.width/5, img.height/5,0, img.width, img.height);
vertex(0, img.height/5,0, 0, img.height);
endShape();
translate(0,0,DistanceGeneral);
}
if (frameCount<1800){
pushMatrix();
translate(0,0,DistanceGeneral);
tint(250,250,250,AlphaGeneral);
beginShape();
texture(a);
vertex(0, 0,0, 0, 0);
vertex(a.width/5, 0 ,0, a.width, 0);
vertex(a.width/5, a.height/5,0, a.width, a.height);
vertex(0, a.height/5,0, 0, a.height);
endShape();
popMatrix();
}
}
void Gui2D(){
// Get the current PeasyCam details to restore later
// offsets = cam.getLookAt();
rotations = cam.getRotations();
// distance = cam.getDistance();
// Get a handle on the current PGraphics?D transformation matrix
PMatrix3D currCameraMatrix = new PMatrix3D(g3.camera);
// This statement resets the camera in PGraphics3D, this effectively
// sets the display to behave as 2D with the origin 0,0 at the top-left
// of the display
camera();
// Draw the HUD using PApplet graphics commands and GUI for Processing
// 2D gui components
G4P.draw();
// Reset the PGraphics3D transformation matrix
g3.camera = currCameraMatrix;
}
// Handle panels events i.e. when a panel is opened or
// collapsed
void handlePanelEvents(GPanel panel){
// Intended to detect panel events but ended up not
// needing it. Left the following code as an example
if(pnl.isCollapsed())
println("Panel has collapsed");
else
println("Panel has opened");
}
// Handles slider events for both horizontal and
// vertical sliders
void handleSliderEvents(GSlider slider){
if(slider == sx){
AlphaGeneral = slider.getValue();
}
if(slider == sy){
DistanceGeneral = slider.getValue();
}
}