How to get my rect in my 5er-grid
in
Programming Questions
•
8 months ago
Hi!
I need your help.
I created this code:
So i have to tell my rect that it should only work if mouseX or mouseY is divisible by 5.
If the coordinate – for example 23 – isnt divisible by 5, the rect should go back to 20.
Can you tell me how to code this or is there a better way to get to my aim?
Thx!
I need your help.
I created this code:
- void setup() {
size(400, 400);
smooth();
}
void draw() {
background(255);
float mX = mouseX;
float mY = mouseY;
fill (#F7C502);
rect (0, 0, mX, mY);
for (int y = 0; y < mouseY; y = y + 5) {
line(0, y, width, y);
}
for (int x = 0; x < mouseX; x = x + 5) {
line(x, 0, x, height);
}
}
So i have to tell my rect that it should only work if mouseX or mouseY is divisible by 5.
If the coordinate – for example 23 – isnt divisible by 5, the rect should go back to 20.
Can you tell me how to code this or is there a better way to get to my aim?
Thx!
1