-
Notifications
You must be signed in to change notification settings - Fork 0
/
ball.pde
56 lines (46 loc) · 832 Bytes
/
ball.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
class Ball {
float homex, x, homey, y, homez, z;
int r;
color c;
boolean isMoving=false;
//3d
Ball(float x_, float y_, float z_, int r_, color c_) {
homex=x=x_;
homey=y=y_;
homez=z=z_;
r=r_;
c=c_;
}
//2d
Ball(float x_, float y_, int r_, color c_) {
homex=x=x_;
homey=y=y_;
r=r_;
c=c_;
}
void display() {
pushMatrix();
translate(x, y, z);
noStroke();
fill(c);
sphereDetail(10);
sphere(r);
popMatrix();
}
//2d
void moveTo(float x_, float y_) {
x = lerp(x, x_, random(0.3));
y = lerp(y, y_, random(0.3));
}
//3d
void moveTo(float x_, float y_, float z_) {
moveTo(x_,y_);
z = lerp(z, z_, 0.1);
}
void colorTo(color c_){
c = lerpColor(c,c_,0.1);
}
void home() {
moveTo(homex, homey, homez);
}
}