So when I click one of those boxes the stroke changes color.
This is what I got so far.
int rectX, rectY; // Position of square button int circleX, circleY; // Position of circle button int rectSize = 50; // Diameter of rect int circleSize = 53; // Diameter of circle color rectColor, circleColor, baseColor; color rectHighlight, circleHighlight; color strokeColor; boolean rectOver = false; boolean circleOver = false;
void mousePressed() { if (circleOver) { currentColor = circleColor; } if (rectOver) { currentColor = rectColor; } }
boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } }
boolean overCircle(int x, int y, int diameter) { float disX = x - mouseX; float disY = y - mouseY; if (sqrt(sq(disX) + sq(disY)) < diameter/2 ) { return true; } else { return false; } }
I have a feeling that I'm doing something really wrong so I decided to start from beginning. With this code I'm trying to make this
The code is
int rectX, rectY; // Position of square button int circleX, circleY; // Position of circle button int rectSize = 50; // Diameter of rect int circleSize = 53; // Diameter of circle color rectColor, circleColor, baseColor; color currentColor; boolean rectOver = false; boolean circleOver = false;
boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } }
boolean overCircle(int x, int y, int diameter) { float disX = x - mouseX; float disY = y - mouseY; if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { return true; } else { return false; } }
This seems easy but since I'm beginner I have no idea how to do this. Am I doing it right? what should I change? Also for the second one it says unexpected token but I can't find any problem with it.