Reference
Lauren McCarthy edited this page
·
12 revisions
Pages 36
- Home
- Archived Content
- Beyond the canvas
- Code of Conduct
- Contributed Tools, Projects, Demos
- Design Principles
- Development
- Development Checklist
- Development – extended
- DOM notes
- Education
- Embedding p5.js
- Frequently Asked Questions
- Friendly Debugger
- Getting Started
- Getting started with WebGL in p5
- Inline documentation
- Instantiation Cases
- Integrating other libraries
- Intro to DOM manipulation and events
- Intro to HTML and CSS
- Issue Labels
- JavaScript basics
- Libraries
- Loading external files: AJAX, XML, JSON
- Local server
- p5.js Contributors Conference at CMU
- p5.js overview
- p5.js, node.js, socket.io
- Positioning your canvas
- Preparing a pull request
- Processing transition
- Reference
- Release steps
- SimpleHTTPServer
- Supported browsers
- Show 21 more pages…
Clone this wiki locally
Basics
The p5.js language looks very similar to the Processing language with a few changes:
- Variables do not have a type. Use var instead of float, int, double, long, char, String, Array, etc.
- A var can be anything -- any of the types mentioned, but also functions.
- Rather than specifying a return type for functions, they are assigned to vars. See the example below.
- Currently, not all Processing functionality is supported in p5.js, and the syntax for a few have changed slightly. See API and API progress for up-to-date documentation of all supported functions and future plans.
Basic sketch
void setup() {
// setup stuff
}
void draw() {
// draw stuff
}function setup() {
// setup stuff
}
function draw() {
// draw stuff
}Supported functions
> API page
Currently supported functions from Processing, as well as new ones supported in p5.js.
> API progress page
API progress and future support.