rollover not working
in
Programming Questions
•
9 months ago
Hello. I'm working on a simple rollover in processing. Currently, the rollover works when I mouse over the ellipse, but it doesn't go away when I move my mouse to another location. Please help if you can.
- float x = random(0, 255);
- float y = random(0, 255);
- float d;
- float radius;
- boolean rollover = false;
- void setup() {
- PFont font = loadFont("DialogInput-12.vlw");
- size (800, 600);
- noStroke();
- smooth();
- }
- void draw() {
- drawData(x, y);
- if (rollover) {
- fill(y);
- textAlign(CENTER);
- text("hahaha", width/2, height/2);
- }
- }
- void drawData(float x, float y) {
- float value = x;
- float d = dist(x, y, mouseX, mouseY);
- float radius = map(value, 0, y, 10, 10);
- fill(x);
- ellipse(x, y, radius, radius);
- if(d < radius) {
- rollover = true;
- } else {
- rollover = false;
- }
- }
1