-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMovings.pde
131 lines (107 loc) · 3.61 KB
/
Movings.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
public abstract class Movings{
public abstract PVector initial();
public abstract float rotation();
public abstract AniSequence sequence(PApplet applet, Object target);
}
public class Square extends Movings{
int circle = 0;
float speed = random(1, 3);
Square(){
speed = random(1, 3);
}
public PVector initial(){
return new PVector(100, 100);
}
public float rotation(){
return 0;
}
public AniSequence sequence(PApplet applet, Object target){
AniSequence seq = new AniSequence(applet);
seq.beginSequence();
seq.add(Ani.to(target, speed, "x", 540, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + PI/2, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "y", 380, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + PI, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "x", 100, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + 3*PI/2, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "y", 100, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + 2*PI, Ani.EXPO_OUT, "onEnd:update"));
seq.endSequence();
circle++;
return seq;
}
}
public class LeftRight extends Movings{
int circle = 0;
boolean back = false;
float speed = 0;
LeftRight(boolean b){
back = b;
speed = random(1, 3);
}
public float rotation(){
return back ? PI : 0;
}
public PVector initial(){
return new PVector(random(100, 500), random(100, 380));
}
public AniSequence sequence(PApplet applet, Object target){
AniSequence seq = new AniSequence(applet);
seq.beginSequence();
seq.add(Ani.to(target, speed, "x", 540, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + PI, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "x", 100, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + 2*PI, Ani.EXPO_OUT, "onEnd:update"));
seq.endSequence();
circle++;
return seq;
}
}
public class TopBottom extends Movings{
int circle = 0;
boolean back = false;
float speed = 0;
TopBottom(boolean b){
back = b;
speed = random(1, 3);
}
public float rotation(){
return back ? PI/2 : 3*PI/2;
}
public PVector initial(){
return new PVector(random(100, 500), random(100, 380));
}
public AniSequence sequence(PApplet applet, Object target){
AniSequence seq = new AniSequence(applet);
seq.beginSequence();
seq.add(Ani.to(target, speed, "y", 380, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + PI, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "y", 100, Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", circle*2*PI + 2*PI, Ani.EXPO_OUT, "onEnd:update"));
seq.endSequence();
circle++;
return seq;
}
}
public class RandomMover extends Movings{
float speed = 0;
RandomMover(){
speed = random(0.5, 2);
}
public float rotation(){
return random(2*PI);
}
public PVector initial(){
return new PVector(random(100, 500), random(100, 380));
}
public AniSequence sequence(PApplet applet, Object target){
AniSequence seq = new AniSequence(applet);
seq.beginSequence();
seq.add(Ani.to(target, speed, "x", random(100, 540), Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "y", random(100, 380), Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, 0.5, "rotation", random(2*PI), Ani.QUAD_IN_OUT));
seq.add(Ani.to(target, speed, "y", random(100, 380), Ani.EXPO_OUT, "onEnd:update"));
seq.endSequence();
return seq;
}
}