# Creating vertical lines

**URL:** <https://discourse.processing.org/t/creating-vertical-lines/24251>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 30, 2020, 9:44pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251 "2020-09-30T21:44:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thughes](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thughes](https://discourse.processing.org/u/thughes)\
**Post date:** [September 30, 2020, 9:44pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/1 "2020-09-30T21:44:03Z")

</div>

Create a user defined function called drawLines() that has a strokeWeight(3) and a random r, g, b value with lower red, medium green and higher blue values.

\*\*\*\*What is it telling me to do with the colors?

This is what I am trying to create…  
The line should start at the top and increase every 20 pixels on the x coordinate. The height is controlled by a random range from 50 to the height of the frame. This method will have the call loop() as the last statement. This will be called in the draw() method.

I can get it to do the first vertical line, and I have a feeling they are all writing on top of each other. What would I do to fix that?

```auto
{
  strokeWeight(3);
    for (int x = 0; x < 400; x++)
{
  stroke(random(0, 100), random(0, 150), random(0, 255));
    line(20, 0, y+20, random(50, 400));
  loop();}
}
`type or paste code here`

```

---

<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:** [September 30, 2020, 9:51pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/2 "2020-09-30T21:51:49Z")

</div>

> [@thughes](#):
>
> `line(20, `

try line (x+20,…

Regarding the color:

try

color col1 = color(random(0,70),  
random(80,170),  
random(170,255));

stroke(col1);

---

<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:** [September 30, 2020, 10:02pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/3 "2020-09-30T22:02:56Z")

</div>

> [@thughes](#):
>
> What is it telling me to do with the colors?

[https://processing.org/tutorials/color/](https://processing.org/tutorials/color/)  
[https://processing.org/reference/](https://processing.org/reference/)  
[https://processing.org/examples/](https://processing.org/examples/)

`:)`

---

<div class="post-metadata">

**Author:** ![thughes](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thughes](https://discourse.processing.org/u/thughes)\
**Post date:** [September 30, 2020, 11:30pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/4 "2020-09-30T23:30:14Z")

</div>

I’ve tried several different ways  
line(20, y, 20, random(50, 400));

```
line(x+20, y, 20, random(50, 400));

line(20, y, 400, random(50, 400));

line(20, y, 0, random(50, 400));

```

nothing works right

---

<div class="post-metadata">

**Author:** ![thughes](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thughes](https://discourse.processing.org/u/thughes)\
**Post date:** [September 30, 2020, 11:41pm UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/5 "2020-09-30T23:41:34Z")

</div>

figured it out!! yay me!

---

<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:** [October 1, 2020, 7:56am UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/6 "2020-10-01T07:56:26Z")

</div>

> [@thughes](#):
>
> `loop();`

This is not necessary when you don’t use noLoop somewhere

for loop loops automatically and draw() does too

Remember to press ctrl-t in your processing to get auto-indent prior to posting here

Warm regards

Christoph

---

<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:** [October 1, 2020, 8:04am UTC](https://discourse.processing.org/t/creating-vertical-lines/24251/7 "2020-10-01T08:04:17Z")

</div>

Did you read the reference about line() ?

It’s a line from a point at x,y to another point at x2,y2

So the order for the parameters is x,y, x2, y2

It’s confusing because all look the same

It’s a matter of practice and experience
