Fill the screen with maroon

Hi I need help with code. It’s actually for school. And they want the ui to look that its going to fill the row with maroon using frameRate from left to right. Once its filled the next row will be filled. Here’s the code I just need to fill them up. I know there are other ways to do it, but I need to fill them as asked, and I only got one part right which is the fill.

float x=0;
float y=0;

void setup(){
  size(500,500);
  frameRate(__);
}

void draw(){
if(x<__){
__(123,17,19);  
fill(123,17,19); 
rect(x,y,25,25);
  
__+=25;
}

____(){
  x = __;
  y = __;
}

}

The idea of this board is not to let others write your code. If you have a specific question for a particular problem, you can ask that question and then people try to help you.

So please ask a specific question about, where you are struggling. What you pasted here looks like the homework task, even without real names for the variables and the framerate.

Just a little hint: Try to divide the problem into subproblems and start with the first one (f.e. filling the gaps)

1 Like

Sorry florian, i was a bit frustrated because it was a 30 minute task i needed to do. It is actually a fill in the blanks type of task. They said filling it up with the necessary code would make it look like filling the screen with maroon with rect from left to right to the next row until it reaches the bottom. I was only able to make it from left to right on the first row with this code:

float x=0;
float y=0;

void setup(){
  size(500,500);
  frameRate(4);
}

void draw(){
if(x<width){
stroke(123,17,19);  
fill(123,17,19); 
rect(x,y,25,25);
  
x+=25;
}
/*
____(){
  x = 0;
  y = x;

}
*/
}

very good!, so next step could be?

if() {} else {//??}

https://processing.org/reference/else.html

2 Likes

Programming is like explaining something to a dumb friend, who must do a task for you

What you tell him…?

Draw rects and increase the y position.

What should he do when reaching the bottom? What happens to x and y?

Grab a pen and paper and figure it out