p5.js

  • Practicing p5.js

    JavaScript
    function setup() {
      createCanvas(650, 400);
      frameRate(8); // slows down the animation to reduce eye strain
    }
    
    
    function draw() {
      background(0);
      for (let x = 0; x <= width; x+= 50) { 
        for (y = 0; y <= height; y+=50) {
          fill(random(255));
          ellipse(x, y, 25, 25);
        }
      }
    }
  • Continuing to practice p5.js

    JavaScript
    let dot = {
      x: 100,
      y: 50
    }
    
    let col = {
      r: 237,
      g: 34,
      b: 93
    } 
    
    function setup() {
      createCanvas(650, 400);
      background(250)
    }
    
    function draw() {
      noStroke();
      dot.x = random(0, width);
      dot.y = random(0, height)
      fill(col.r, col.g, col.b, 20);
      ellipse(dot.x, dot.y, 24, 24);
    }
  • Learning how to make generative art with p5.js

    JavaScript
    function setup() {
      createCanvas(400, 400);
    }
    
    function draw() {
      background(0, 0, 50);
    
      fill(200, 120, 100);
      noStroke();
      rect(20, 25, 200, 200);
     
      stroke(255, 255, 255, 200);
      strokeWeight(5)
      line(0, 0, 360, 400)
    }