NMD 105 Creative Coding I

P5js Coding Environments

"Green Brain99099" by Luis Ruiz

Who made p5js?

Mccarthy Lauren A
Lauren McCarthy, founder
Turner Moira P5js Headshot
Moira Turner, maintainer

Coding environments

P5js editor

P5js "library" in HTML

<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/p5@1.2.0/lib/p5.js"></script>
    <script src="sketch.js"></script>
  </head>
  <body>
    <main>
    </main>
  </body>
</html>

p5js v. JavaScript

Dialects require a specialized environment

Environment
Expression
Response
Maine
"Ayuh"
It Aint Much But Honest Work Meme
Away
"Ayuh"
Wait You Guys Are Getting Paid Meme
p5js
rect( 100, 100, 50, 50 )
🔲
JavaScript
rect( 100, 100, 50, 50 )
❌ "rect is undefined!"

P5js Interface

Command-S when you've clicked in the code pane saves the sketch.

Command-S elsewhere on the screen tries to save the entire web page to your desktop.

🐞 If your old code appears when you click the New Sketch button, try File > New.

🐞 Disable autorefresh when writing a loop, or you could get caught in an infinite refresh.

🐞 Control-Z doesn't always undo. Worried about ruining your code? Duplicate the sketch.

Other P5js-like coding environments

OpenProcessing.org

Processing

🤔 Confused? Just stick with the P5js editor

/