Hey there Guys,
I was wondering if you could offer me some insight in to how I can color each ellipse randomly that is drawn by an array.
Currently I have created a second array for colors which it draws from when the sketch is launched but each of the ellipse comes out the same color. How can I make each ellipse select the colour randomly. Here is some of the code.
void setup() {
index = int(random(colors.length));
size(500, 500);
for (int i = 0; i < words.length; i++) // X Values
{
words[i] = new word(width / 2, height / 2, i*2, index );
}
}
void draw() {
background(yellow);
for (int i = 0; i < words.length; i++) // X Values
{
words[i].display();
words[i].floatAimlessly();
}
}
// Draw the blob to the canvas
void display() { // Defines how the words will be displayed
pushMatrix();
textSize(70);
noStroke();
//fill(random(255,200),random(100,255),0);
fill(colors[index]);
ellipse(pos.x,y,r,r);
//text(“Array.”, pos.x, y); // Specify a z-axis value
popMatrix();
}
Here is an image, you can see each ellipse is the same color forming one large shape. I’d like to select from these colors.
color yellow = color(255, 188, 103);
color red = color(218, 114, 126);
color pink = color(172, 108, 130);
color violet = color(104, 92, 121);
color blue = color(62, 78, 89, 100);