View on GitHub

p5js

Download this project as a .zip file Download this project as a tar.gz file

Using code to make interactive art

Brian Mueller


Introduction


Getting Started


Understanding the Structure


Shapes


Color


Variables


Interaction

Read more in the documentation under Events (including mobile: touchX, touchY, etc).


Conditionals

if (condition){
  // code
} else if (condition){
  // code
}
else {
  // default
}

Loops

while (condition) {
  // code
}
do {
  // code
} while (condition);
for (var i = 0; i < num; i++) {
  // code
}

Functions

// defining your function
function myFunction(optional parameters){
  // code
}

// calling your function
myFunction(arguments);

Arrays

var arrayName = [item1, item2, ...];
arrayName[1]; // returns item2

Examples


Extra