Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 881a74d

Browse files
committed
added slow time example
1 parent 62dfb6f commit 881a74d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import android.os.Vibrator;
2+
import android.content.Context;
3+
4+
ArrayList<PVector> dots;
5+
int totalMin = 24 * 60;
6+
Vibrator vibrator;
7+
8+
void setup() {
9+
fullScreen();
10+
frameRate(1);
11+
dots = new ArrayList<PVector>();
12+
Context context = (Context) surface.getComponent();
13+
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
14+
}
15+
16+
void draw() {
17+
int time = hour() * 60 + minute();
18+
if (time == 0) dots.clear();
19+
float x = map(time, 0, totalMin, 0, width);
20+
if (ambientMode) {
21+
background(0);
22+
noFill();
23+
stroke(255);
24+
line(x, 0, x, height);
25+
for (PVector d: dots) {
26+
ellipse(d.x, d.y, 10, 10);
27+
}
28+
} else {
29+
background(255);
30+
fill(0);
31+
noStroke();
32+
rect(0, 0, x, height);
33+
for (PVector d: dots) {
34+
ellipse(d.x, d.y, 10, 10);
35+
}
36+
}
37+
38+
for (int i = dots.size()-1; i >= 0; i--) {
39+
PVector d = dots.get(i);
40+
if (d.x < x) {
41+
dots.remove(i);
42+
vibrator.vibrate(500);
43+
}
44+
}
45+
}
46+
47+
void mousePressed() {
48+
dots.add(new PVector(mouseX, mouseY));
49+
}

0 commit comments

Comments
 (0)