Reconfigure - the canvas

Hi!

I hope you could help me here.

I got this code.

void setup() {
  size(500, 500);
  noStroke();
}

void draw() {
  background(0);
  fill(0,200,0);
  int t = 0;
  float z = map(millis(), 0, 20000, 0, 400);
  for ( int i = 0; i < 20; i++) {
    for ( int j=0; j<20; j++) {
      if ( t < z ) {
        rect(25*j, 25*i, 25, 25);
      }
      t++;
    }
  }
}

It “paints” 500x500 canvas with a 25px brush in 20 seconds.

I can’t figure how to morph it si i can effectively use the command frameRate(25) instead of milli() (which i think makes the program run in 25 frames). Also I can’t seem to change the green to the value (123,17,19) and the black default background to white.

Thanks

Hey Apollo I think u r a beginner so I would recommend going to the processing reference if u have any more doubts regarding any other functions

void setup() {
  size(500, 500);
  noStroke();
  frameRate(25)
}

void draw() {
  background(255);
  fill(123,17,19);
  int t = 0;
  float z = map(millis(), 0, 20000, 0, 400);
  for ( int i = 0; i < 20; i++) {
    for ( int j=0; j<20; j++) {
      if ( t < z ) {
        rect(25*j, 25*i, 25, 25);
      }
      t++;
    }
  }
}
2 Likes

Hello. That’s my code.
I wrote that code for you as an example in this thread: Painting a canvas

You could have modified it yourself, if you understood it.
You could have changed the colors easily, if you understood it.
You wouldn’t have added a call to frameRate() again, if you understood it.

But you clearly do not understand it.

You apparently haven’t even TRIED to understand it.

You have brought great shame on yourself, and your family, and your clan, and your town.
Shame. Shame. Shame.
Try doing your own homework from now on.
You’re lucky you’re not getting banned.

hi @apollo, as written above it’s not cool that you repost the code without reference until you get a solution :disappointed: as the guideline suggests, you first need to try what you can, and then you can ask for questions.

@TfGuy44 sorry for what happened. You don’t have to be nice in this situation, but since this is a public forum, please don’t blame like that. I guess we should simply suggest to read the guideline.

1 Like