p5 examples

A collection of code examples for p5.js (in progress).

Hello, World!

Hello, World!

hello.js

function setup() {
  createCanvas(400, 400);
}

let x = 50;

function draw() {
  background(0);
  ellipse(x, 200, 100, 50);
  x++;

  if (x > width+50) 
    x = -50;
}

HTML

<script src="p5.min.js"></script>
<script src="hello.js"></script>

hello.zip (includes p5.min.js)