我正在处理一个简单的翻转。目前,当我将鼠标悬停在椭圆上时,翻转有效,但当我将鼠标移动到另一个位置时它不会消失。
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;
}
}