forked from michael/tween
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtween2.pjs
48 lines (38 loc) · 786 Bytes
/
tween2.pjs
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
class ColoredObject {
float x;
float y;
float blueLevel;
float blueLevelTarget;
Tween t;
public ColoredObject(float x, float y, blueLevel, blueLevelTarget) {
this.x = x;
this.y = y;
this.blueLevel = blueLevel;
this.blueLevelTarget = blueLevelTarget;
t = new Tween(this, "blueLevel", Tween.strongEaseInOut, blueLevel, blueLevelTarget, 2);
}
public void update() {
t.tick();
}
public void draw() {
fill(123, 211, blueLevel);
noStroke();
ellipse(x, y, 100, 100);
}
public void restart() {
t.start();
}
}
ColoredObject co;
void setup() {
size(400, 150);
co = new ColoredObject(100,70, 255, 0);
}
void draw() {
background(244);
co.update();
co.draw();
}
void mousePressed() {
co.restart();
}