当一个矩形悬停时,如何着色单个矩形?下面使用的具体方法确实没有给出任何关于如何解决这个问题的想法。它使用单独的矩形在窗口中生成一个网格。怎样才能听到mouseX
和mouseY
并在不破坏此代码的情况下为一个矩形着色?谢谢。如何在盘旋时直接着色一个矩形?
int cols,rows;
int scl = 20;
int gridsize = 0;
void setup(){
size(400,400);
int w = 400;
int h = 400;
cols = w/scl;
rows = h/scl;
}
void draw() {
//mouseX, mouseY
background(r,g,b);
for (int x = 0; x < cols; x++){
for (int y = 0; y < rows; y++){
stroke(55);
//noFill();
fill(50,50,50);
rect(x*scl,y*scl,scl,scl);
}
}
}
仅供参考,我正在使用Processing 3 for Java。
感谢您花时间为我解决这个问题,我非常感谢。正是我想要的! – Icy4614