Parallel&horizontal lines using loops

Hello
please i need help in my homework:

Exercise: draw random parallel and horizontal lines using loops.The length of each line is a random number between 0 and 44.

Thanks

I would use a for loop to make different y positions for your lines.

The x positions will need to differ by a random amount.

You can draw lines with the line() function.

You can generate random numbers with the random() function.

It is hard to help you more without seeing your code.

Please post your current code for more help.

For more help, post your current code.

You should post your code. Then we can help you more.

Notice that I’ve said you should post your code three times.
That’s because it’s important. You should post it.

2 Likes

for (int y=0;y<=height;y=y+6){
line((int)random(45),y,(int)random(45),y);
}
for (int x=0;x<=width;x=x+12){
line(x,(int)random(45),x,(int)random(45));

Parallel != vertical != horizontal