# Need Help to complete my homework :)

**URL:** <https://discourse.processing.org/t/need-help-to-complete-my-homework/29738>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 30, 2021, 6:34am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738 "2021-04-30T06:34:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcellgz](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Marcellgz](https://discourse.processing.org/u/Marcellgz)\
**Post date:** [April 30, 2021, 6:34am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/1 "2021-04-30T06:34:40Z")

</div>

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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3ba6777e93c6b516e0708e73bb5ace6a4f5cefc9.png)

```auto
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);
  }
 }
}

```

---

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [April 30, 2021, 7:47am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/2 "2021-04-30T07:47:18Z")

</div>

Try with two for loops [https://processing.org/reference/for.html](https://processing.org/reference/for.html)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 30, 2021, 8:25am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/3 "2021-04-30T08:25:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 30, 2021, 9:14am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/4 "2021-04-30T09:14:10Z")

</div>

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

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

[![](https://img.youtube.com/vi/esKLU3dJo70/maxresdefault.jpg "6.2: Two Loops / Grid Exercise - Processing Tutorial") ](https://www.youtube.com/watch?v=esKLU3dJo70)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 30, 2021, 10:30am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/5 "2021-04-30T10:30:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 30, 2021, 10:52am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/6 "2021-04-30T10:52:57Z")

</div>

Hello,

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

- [https://processing.org/](https://processing.org/)

And Google search for:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/077193e00c60a541866fd598213788530fd90302.png)

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:

- [Coordinate System and Shapes \ Processing.org](https://processing.org/tutorials/drawing/)

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.

`:)`

---

<div class="post-metadata">

**Author:** ![Marcellgz](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Marcellgz](https://discourse.processing.org/u/Marcellgz)\
**Post date:** [April 30, 2021, 4:13pm UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/7 "2021-04-30T16:13:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 30, 2021, 4:51pm UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/8 "2021-04-30T16:51:53Z")

</div>

good start! but please format your code!

[https://www.khm.de/~n.hieda/discourse-code.mp4](https://www.khm.de/~n.hieda/discourse-code.mp4)

---

<div class="post-metadata">

**Author:** ![Marcellgz](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Marcellgz](https://discourse.processing.org/u/Marcellgz)\
**Post date:** [May 1, 2021, 4:03am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/9 "2021-05-01T04:03:43Z")

</div>

Done… so… what to do now…

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 1, 2021, 5:46am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/10 "2021-05-01T05:46:52Z")

</div>

> [@Chrisir](#):
>
> Both run from 0 to 10
> 
> Then calc the individual position of the rect()

You should do it like this… can you try?

---

<div class="post-metadata">

**Author:** ![Marcellgz](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Marcellgz](https://discourse.processing.org/u/Marcellgz)\
**Post date:** [May 1, 2021, 7:43am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/11 "2021-05-01T07:43:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 1, 2021, 7:50am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/12 "2021-05-01T07:50:18Z")

</div>

I mean the for loops

Increase them by 1

and then say` x=i*10;`

---

<div class="post-metadata">

**Author:** ![Marcellgz](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Marcellgz](https://discourse.processing.org/u/Marcellgz)\
**Post date:** [May 3, 2021, 2:00am UTC](https://discourse.processing.org/t/need-help-to-complete-my-homework/29738/13 "2021-05-03T02:00:27Z")

</div>

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

```auto
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);
  }
 }

```

}
