-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMolecules.pde
43 lines (36 loc) · 994 Bytes
/
Molecules.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
class Molecules{
float x;
float y;
float tempValue;
float phValue;
float xValue;
color c;
float d;
//constructor
Molecules(float d) {
this.x = random(width);
this.y = random(height);
this. c = color(0,0,255,60);
this.d = d;
}
//methods
void setSensorValue(float tempValue, float phValue, float xValue){
this.tempValue = tempValue;
this.phValue = phValue;
this.xValue = xValue;
}
void display(){
float mappedColor = map(this.phValue,0,90,0,255);//color change with change in humidity
this.c = color(mappedColor,0,255,60);
noStroke();
fill(c);
ellipse(this.x, this.y, this.d, this.d);
}
void move(){
float intensity = map(this.tempValue,0,50,1,15);
this.x = this.x + random(-intensity,intensity);
this.y = this.y + random(-intensity,intensity);
this.x = constrain(this.x,0,width+10);
this.y = constrain(this.y,0,height+10);
}
}