None of this feel particularly easy to me - I find it somewhat hard to predict what will happen with some loops, outside of the column worksheet exercises. It doesn’t help that when I get it wrong, there’s a high probability I need to restart the p5 window because it crashes. I think I will become more comfortable with loops as I work with them more, but currently it’s still really difficult for me.

I am pretty happy with my simple, yet very busy looking Laser Lines piece. While I am still struggling with loops, I felt like it might be nice to go back to the For Loop example we worked on in class. I was also interested in injecting randomness and some interactivity into the code. Initially, I was not getting results I wanted until I discovered being able to control the seed that random is basing itself off of (thankfully, I have some previous understanding of random seeds from working in TouchDesigner a bunch). From there I thought about my past use of ‘millis’ and realized I could sort of animate random. It looked way too crazy just having random changing every millisecond, so I then added the control of mouseIsPressed, so I could control when that behavior happens. After playing with the lines, how many would look good, etc. I decided to see what would happen if I tied ellipses into the mix.

I am aware I am using mouseX mouseY and mouse pressing a lot in my projects, and I’d like to branch out, either seeing ways I can refine the behavior more, or find other points of interactivity.

Some stuff I am still trying to figure out regarding the composition:

stroke modes - how can I get the outlines to blend into each other, forming larger shapes when they collide?

Can I make another version of random to decouple the ellipses from the lines?

//currentSeed will work with random later
let currentSeed;
let ovalSeed;
function setup() {
  createCanvas(1000, 1000);
  stroke(0);
  // setting the clock to change the seed as the milliseconds count
  currentSeed = millis();
}

function draw() {
  background(0, 255, 100);

  // when the mouse is clicked, the counter will update currentSeed
  if (mouseIsPressed) {
    currentSeed = millis();
  }

  //had to find a way to make random more controlled, found randomSeed which worked
  randomSeed(currentSeed);

  // very simple loop, like we learned in class, it will make lines and ellipses until it hits 1500 each
  for (let i = 0; i < 1500; i++) {
    //setting random starting points for the lines to generate at
    let x1 = random(width);
    let y1 = random(height);

    //the other point on the lines will follow the mouse
    let x2 = mouseX;
    let y2 = mouseY;

    
    //drawing all the shapes
    //strokeWeight(5)
    ellipse(x1, y1, x2, y2);

    stroke(255, 0, 0);
    line(x1, y1, x2, y2); 

    strokeJoin(ROUND);
    stroke(0, 255, 0);
    fill(0);
    circle(mouseX, mouseY, 50);
  }
}