changing ellipse fill with click
in
Programming Questions
•
8 months ago
Alright. So I want to have each of my ellipses change specific colors when I click on them. However, I am at a complete loss on how to do that. I tried to do the if() statement, but whenever I try to do anything in mousePressed nothing happens. What can I do?! Here's what I have so far:
- PImage brain;
//string word[]{"homework","boyfriend","food","coffee","hate","love","college","oregon","no","yes","beer","party","late","time","class","money"};
int[] amount = {31, 150, 21, 60, 72, 231, 23, 43, 240, 130, 12, 62, 15, 65, 111, 86
};
//int level[]{5,5,2,2,5,4,5,1,3,2,1,4,5,2,2,5};
color[] circles = { #F2B66D, #F2955E, #F26A4B, #BF4949, #401D15};
color[] levels = {#929AFF, #5F69E5, #2B39EA, #000FD1, #0C1585};
color[] palette1 = circles;
color[] palette2 = levels;
int counter=1;
void setup() {
size(800, 800);
brain = loadImage("image.png");
brain.resize(800, 800);
background(brain);
smooth();
stroke(58, 111, 222);
}
void draw() {
println(mouseX);
println(mouseY);
//circle1,homework 5
fill(palette1[4], 3);
ellipse(620, 351, amount[0], amount[0]);
//circle2,boyfriend 5
fill(palette1[4], 3);
ellipse(625, 440, amount[1], amount[1]);
//circle3,food 2
fill(palette1[1], 3);
ellipse(581, 358, amount[2], amount[2]);
//circle4,coffee 2
fill(palette1[1], 3);
ellipse(531, 368, amount[3], amount[3]);
//circle5,hate 5
fill(palette1[4], 3);
ellipse(573, 301, amount[4], amount[4]);
//circle6,love 4
fill(palette1[3], 3);
ellipse(147, 455, amount[5], amount[5]);
//circle7,college 5
fill(palette1[4], 3);
ellipse(521, 411, amount[6], amount[6]);
//circle8,oregon 1
fill(palette1[0], 3);
ellipse(504, 306, amount[7], amount[7]);
//circle9,no 3
fill(palette1[2], 3);
ellipse(444, 170, amount[8], amount[8]);
//circle10,yes 2
fill(palette1[1], 3);
ellipse(427, 425, amount[9], amount[9]);
//circle11,beer 1
fill(palette1[0], 3);
ellipse(472, 350, amount[10], amount[10]);
//circle12,party 4
fill(palette1[3], 3);
ellipse(437, 323, amount[11], amount[11]);
//circle13,late 5
fill(palette1[4], 3);
ellipse(375, 297, amount[12], amount[12]);
//circle14,time 2
fill(palette1[1], 3);
ellipse(356, 343, amount[13], amount[13]);
//circle15,class 2
fill(palette1[1], 3);
ellipse(244, 264, amount[14], amount[14]);
//circle16,money 5
fill(palette1[4], 3);
ellipse(298, 399, amount[15], amount[15]);
if (counter == amount[0]) {
fill(palette2[4]);
}
else if (counter == amount[1]) {
fill(palette2[4]);
}
else if (counter == amount[2]) {
fill(palette2[1]);
}
else if (counter == amount[3]) {
fill(palette2[1]);
}
else if (counter == amount[4]) {
fill(palette2[4]);
}
else if (counter == amount[5]) {
fill(palette2[3]);
}
else if (counter == amount[6]) {
fill(palette2[4]);
}
else if (counter == amount[7]) {
fill(palette2[0]);
}
else if (counter == amount[8]) {
fill(palette2[2]);
}
else if (counter == amount[9]) {
fill(palette2[1]);
}
else if (counter == amount[10]) {
fill(palette2[0]);
}
else if (counter == amount[11]) {
fill(palette2[3]);
}
else if (counter == amount[12]) {
fill(palette2[4]);
}
else if (counter == amount[13]) {
fill(palette2[1]);
}
else if (counter == amount[14]) {
fill(palette2[1]);
}
else if (counter == amount[15]) {
fill(palette2[4]);
}
1