Skip to content

Instantly share code, notes, and snippets.

@witt3rd
Last active June 18, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save witt3rd/8294978383ad4d9db5683f86b5cc39d6 to your computer and use it in GitHub Desktop.
Save witt3rd/8294978383ad4d9db5683f86b5cc39d6 to your computer and use it in GitHub Desktop.

p5js

This is a collection of notes on the p5.js library. There is a corresponding repo with the configured project and sample code described here.

Basic setup

The easiest way to get setup with a auto-reloading ES6 server is with the p5-manager.

Sketch Functions

Setup

Where one-time initialization code goes. Minimally, we setup a canvas:

  createCanvas(width, height)

Draw

Code to draw a single frame.

Primitives

Canvas

(0,0) --- (x,0)
  |         |
(0,y) --- (x,y)
createCanvas(width, height)

Shapes

line(x1,y1,x2,y2)

Color

background()
fill()
stroke()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment