-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRing.pde
62 lines (51 loc) · 1.45 KB
/
Ring.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
class Ring {
PFont breathword;
float x, y; // X-coordinate, y-coordinate
float diameter; // Diameter of the ring
boolean on ; // control whether to contract or grow
float max=250,min=50;
void start(float xpos, float ypos) {
x = xpos;
y = ypos;
on = false;
diameter = max;
}
void grow() {
background(diameter/max*80);
breathword = loadFont("FuturaLT-Light-48.vlw");
textFont(breathword,diameter/4.5);
fill(0,120);
textAlign(CENTER, CENTER);
text("Breath In", 80+(width-100)/2, height/2);
if (diameter >= max) {
on =false;
}
else diameter += 11;//constant speed of breath in
}
void contract(float speed) {
background(diameter/max*80);
breathword = loadFont("FuturaLT-Light-48.vlw");
textFont(breathword,diameter/2.5);
fill(0,120);
textAlign(CENTER, CENTER);
text("Out", 80+(width-100)/2, height/2);
if (diameter <= min) {
on =true;
}
if (diameter >= max) {
on =false;
}
diameter -= 2*speed*(max-min)/(7*w);
}
void display() {
fill(155,50);
/*strokeWeight(4);
stroke(155, 50);*/
noStroke();
ellipse(x, y, diameter, diameter);
//rect(x-diameter/2,y-diameter*5/6+50,diameter,diameter/3);
fill(20,50);
//ellipse(x-30, y-50, 7, 10);
//ellipse(x+30, y-50, 7, 10);
}
}