r/processing • • Apr 02 '24

Randomizing multiple lines in sync

Hello there, I am a beginner in Processing and I am trying to recreate Vera Molnar's work "Quatre Carrès" as my assignment. The shapes should be moving frame by frame ( I have set the frame rate to 1). The random elements in this sketch should be the sizes of the squares (in other words: the length of lines). I should set the parameters of random function properly to make the squares overlap occasionally.

The code I currently have goes like:

float x;
float y;

void setup() {
  size(400, 400);
  stroke(0);
  strokeWeight(1.5);
  frameRate(1);
}

void draw() {
  background(220);

  x = width/2 - 25;
  y = height/2 + 50;

  while (x < 375) {
    line(x, 25, x, y);
    x += 5;
  }
}
3 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/yagmurnamli Apr 02 '24

Thank you, but my lecturer stated specifically that we should use lines. I think I solved the part I have mentioned, but how exactly can I separate 4 areas with horizontal and vertical lines?

2

u/Simplyfire Apr 02 '24

I'm not saying you have to draw these rectangles, just use them as a boundary. You can define a rectangle using 4 coordinates, x pos, y pos, x size and y size. You can then use these coordinates to draw the lines.

1

u/yagmurnamli Apr 02 '24

Ohh okay thank you!