p5 examples

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

Image

let img;

function preload() {
    img = loadImage('cat.png');
}

function setup() {
    createCanvas(400, 400);
    noCursor();
    img.resize(40, 40);
}

function draw() {
    background(100);
    image(img, mouseX, mouseY);
}

cat.js cat.png