Need Help to complete my homework :)

Hello, i really need help… i have a task from my teacher to create this thing… but i have no clue… me and my friends are so very confused…
Screenshot_7

void setup() {
  size(200,200);
  background(255);
}

void draw() {
  for (int x = 35; x < 165; x += 10){
  for (int y = 30; y < 165; y += 15){
  fill(0);
  rect(x , y, 3, 10);
  }
 }
}

Try with two for loops https://processing.org/reference/for.html

1 Like

Yeah, best when you show your own code

You need one for loop for the columns and inside of it one for loop for the rows of the grid

Both run from 0 to 10

Then calc the individual position of the rect()

Also the y position increases slightly

1 Like

I have to admit that this exercise seems quite challenging even for experienced coders if you want to make exactly the same :frowning:

But relax and start from something simple - perhaps this tutorial gives you an idea of how to make repeated shapes!

2 Likes

Some of the rect appear different on the corners but maybe we skip this detail

1 Like

Hello,

There are resources (tutorials, examples, references, books, etc.):

And Google search for:
image

I always like to start with points() for layout and then replace with shapes later.

You need a basic understanding of the co-ordinate system and shapes:

Also:

  • Nested for loops() is one way to do it.
  • Find the reference for
    *for()
    *points()

As a beginner you may need to start with some of the other tutorials and start writing code.

I do not need to see your code.

:)

1 Like

Thanks for help guys…
This is my code
size(200,200);
background(255);

for (int x = 35; x < 165; x += 10){
for (int y = 30; y < 165; y += 15){
fill(0);
rect(x , y, 3, 10);
}
}

But i didn’t know how to increase the y position

good start! but please format your code!

Done… so… what to do now…

You should do it like this… can you try?

hmmm… i dont understand… can you give me a example?

I mean the for loops

Increase them by 1

and then say x=i*10;

1 Like

Thank You for your Help friends!
Now i have finish my assignment
This is my code:

void setup(){
size(300,300);
background(255);
}

void draw(){
for (int x = 50; x <= 250; x += 16) {
  for (int y = 40; y <= 300; y *= 1.3) {
    fill(0);
    rect(x,y,3,10);
  }
 }

}

1 Like