Creating vertical lines

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?

{
  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`

try line (x+20,…

Regarding the color:

try

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

stroke(col1);

https://processing.org/tutorials/color/
https://processing.org/reference/
https://processing.org/examples/

:)

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

figured it out!! yay me!

1 Like

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

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