Randomized lines on a grid - homework help - it's kinda due tonight

Hi, I’m really new to processing and I need some help on an idea I don’t really know where to start at.

What I have now is a grid, and I’ll make it not visible later, it just acts as a guideline.

I want a vertical line to appear in every single box of the grid, with randomized thickness and location inside each grid box. I don’t think I have the right general idea to pull this.

so would I was thinking I code a line appearing randomly in one square with different thickness first, then loop it down the x-axis then the y-axis of the grid.

Is there another method or idea anyone would suggest?

ah- sorry if it’s hard to read, I don’t know how to upload what I have so I just copied pasted it directly in text from processing.

int x;
int y;

int gridX = 20;
int gridY = 30;

int gridXB = 120;
int gridYB = 120;

void setup()
{
size(1200, 900);
background(230);
noStroke();
frameRate(10);
}

void draw()
{
rectMode(CENTER);
noFill();
stroke(0);
strokeWeight(1);
rect(width/2, height/2, 1100, 800);

//first square starts within 100 from the boarder (20+80)
//grid squares end before the boarder (120 away from screen size)
for (int x = gridXB; x <= width-120; x += gridX)
{
for (int y = gridYB; y <= height-120; y += gridY)
{
strokeWeight(0.25);
noFill();
rect(x, y, 19, 29);

  //the line randomly generates within each square of the grid
  //the line varies from different thickness
  //looping from the first line down the x-axis
  }
}

{

when you want a line within each cell of your grid you’re almost there:

for example

strokeWeight(random(1,8)); 

line (x+3, y, x+3, y+gridY-1);

Hello,

How to Format Your Code:
https://discourse.processing.org/faq#format-your-code

:)

or since you use

rectMode(CENTER);

try

     strokeWeight(random(1, 18)); 

      line (x, y-gridY/2+2, 
        x, y+gridY/2-2);

Only ONE line

when you want to show only one line that’s moving:

You can count the current cell within the for-loop just by adding 1 to a counter named currentCell (add 1 within the for-loop).

Also make a counter2++ at the very end of draw() where you store in which cell the line has to appear.

Surround the drawing line() command above with

if(currentCell==counter2) {
    ...
}

Init both variables before setup() and set currentCell to 0 before the for-loops.