-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlide.pde
More file actions
69 lines (53 loc) · 1.24 KB
/
Copy pathSlide.pde
File metadata and controls
69 lines (53 loc) · 1.24 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
public class Slide {
private int id;
private PVector pos;
private PVector targetPos;
private int bgcolor;
//Shift loop timer
private int clicStart ;
private int clicNext ;
public Slide(int id) {
this.id = id;
this.pos = new PVector(0, 0);
this.targetPos = new PVector(0, 0);
this.bgcolor = color(
random(50, 100),
random(50, 100),
random(50, 100)
);
}
public void setInitPos(PVector initPos) {
this.pos = new PVector(initPos.x, initPos.y);
}
public void run() {
update();
render();
}
private void update() {
if (millis() <= clicNext) {
float amt = map(millis(), clicStart, clicNext, 0.0f, 1.0f );
pos.x = lerp(pos.x, targetPos.x, amt);
}
}
private void render() {
pushMatrix();
translate(pos.x, pos.y);
fill(bgcolor);
ellipse(width/2, height/2, height, height);
//rect(0, 0, width, height);
fill(200);
textSize(250);
textAlign(CENTER, CENTER);
text(id+1, width/2, height/2-30);
popMatrix();
}
public void moveIt(float _newX, int time) {
if (time == 0) {
pos.x = _newX;
} else {
targetPos.x = _newX;
clicStart = millis();
clicNext = clicStart + time;
}
}
}