將滑鼠移到灰色圓圈時,圓圈會開始閃爍及變色.
void setup()
{
size(550,550);
colorMode(HSB);
smooth();
noStroke();
frameRate(100);
}
void draw()
{
background(0);
for (int i=50; i<=500; i+=50) {
for (int j=50; j<=500; j+=50) {
ellipse(i, j, 40, 40);
}
}
for (int i=50; i<=500; i+=50) {
for (int j=50; j<=500; j+=50) {
float x = mouseX;
float y = mouseY;
float k = dist(x, y, i, j);
float d = random(0, 360);
if (k<=17.5) {
fill(d, 255, 100);
ellipse(i, j, 50, 50);
} else { fill(120);
ellipse(i, j, 40, 40);
}
}
}
}
沒有留言:
張貼留言