p5.js examples

Some p5.js examples. To run and edit files locally, click the download button below.

Open the html file in a text editor to change the code. Open with the web browser to run the code.


  let width = 800
  let height = 600

  function setup() {
    createCanvas(width, height)
  }

  let line_pos = 0

  function draw() {
    background(0)

    stroke(255)
    strokeWeight(2)
    line(0, line_pos, width, line_pos)

    line_pos += 1
    if (line_pos > height)
      line_pos = 0
  }