Hi again!
Now I´ve got the visual look of the program. In the white boxes the I will display the data from the Arduino and calculated values. And I would like to ba able to change the coloring of the balls(color not in gray scale...)
I thought I solved it yesterday but i didn´t...
How can I get it in HSB color? Where do I write the code? In draw or in constructor(I have tried several places but it didn´t work)
Here is the "visual" (interface) code...
Now the tricky bit starts...
Spot sp1; // Declare the object
Spot sp2;
Spot sp3;
Spot sp4;
Spot sp5;
void setup() {
size(500, 250);
smooth();
noStroke();
sp1 = new Spot(180,50, 100, 15, 0.5); // Construct the object
sp2= new Spot(50,100,100,50,1.1);
sp3= new Spot(180,150,100,40,5.0);
sp4= new Spot(255,200,100,30,3.0);
sp5= new Spot(180,250,100,20,1.2);
}
void draw() {
fill(0, 15);
rect(0, 0, width, height);
fill(0);
sp1.move();
sp1.display();
sp2.move();
sp2.display();
sp3.move();
sp3.display();
sp4.move();
sp4.display();
sp5.move();
sp5.display();
rect(300,0,200,250);
PFont font;
font = loadFont("Tahoma-Bold-12.vlw");
textFont(font);
fill(255);
text(" Description",310,25);
text("OD",5,220.5);
text("\u00B5",10,18.5);
text("\u2206\u00B5",5,35.5);
text("-TubeSpec\u2122-",115,240);
fill(0);
text("Speed=Growth rate",330,50);
text ( "Ball size = Optical density",330,68);
text("Ball colour=",330,86);
text("White",330,110);
text("Increased Growth rate",330,122);
text("Gray",330,146);
text("Unchanged Growth rate",330,158);
text("Dark gray",330,182);
text("Decreased Growth rate",330,194);
fill(255);
rect(23,5,45,12.5);
rect(75,5,45,12.5);
rect(127,5,45,12.5);
rect(178,5,45,12.5);
rect(228,5,45,12.5);
rect(23,23.5,45,12.5);
rect(75,23.5,45,12.5);
rect(127,23.5,45,12.5);
rect(178,23.5,45,12.5);
rect(228,23.5,45,12.5);
rect(23,208.5,45,12.5);
rect(75,208.5,45,12.5);
rect(127,208.5,45,12.5);
rect(178,208.5,45,12.5);
rect(228,208.5,45,12.5);
}
class Spot {
color c; // fill color
float x, y; // X-coordinate, y-coordinate
float diameter; // Diameter of the circle
float speed; // Distance moved each frame
int direction = 1; // Direction of motion (1 is down, -1 is up)
// Constructor
Spot(color colour,float xpos, float ypos, float dia, float sp) {
c = colour;
x = xpos;
y = ypos;
diameter = dia;
speed = sp;
}
void move() {
y += (speed * direction);
if ((y > -50+(height - diameter / 2)) || (y < 50+ (diameter / 2))) {
direction *= -1;
}
}
void display() {
fill(c);
ellipse(x, y, diameter, diameter);
}
}