I am trying to complete a school project and this is what I have right now (see below). I want to assign a random color to each circle every time - but right now, I am stuck at where the same color is being assigned to all the circles (a random color each time)… Can anyone help me? I want each circle to have a different shade of brown
Tribble[] tribble = new Tribble[50];
color aColor = color( random(255),random(255),random(255) );
void setup() {
size(400, 400);
background(255);
frameRate(30);
for (int i = 0; i < tribble.length; i++) {
tribble[i] = new Tribble(random(0, 400), random(0, 400));
}
}
void draw() {
background(255);
tribble[(int)random(tribble.length)].excited();
for (int i=0; i<tribble.length; i++) {
tribble[i].display();
}
}
class Tribble {
float xPos, yPos;
int start;
float time;
int offset;
boolean wakeup;
Tribble(float x, float y) {
xPos = x;
yPos = y;
}
//Makes the tribble excited
void excited() {
time = (frameCount/60) % 7;
if (time >= 4 && time < 6) xPos += random(-1, 1);
}
//Draws the tribble.
void display() {
ellipseMode(CENTER);
fill(aColor);
ellipse(xPos, yPos, 50, 50);
}
}
And now, when you’re calling fill(aColor) in your display function, you should be getting different colors. You can also experiment with different color spaces like colorMode(HSB) and have acolor=color(random(255),255,255) so that you specify a certain range of hue you like.