To get started with p5.js, you first need to download the p5 library and some blank template files. Eventually, you will learn how to set up everything for yourself, but in the meantime, I will provide you with a folder containing everything you need. Please download the following zip’d “empty p5 project” directory from the course repo.
Next, unzip the directory, if your browser did not do this for you.
Then, move it to the top level of your course repository.
Create a new directory/folder in your repo labeled course-work
.
In this directory, add a new directory labeled, week-3
.
Finally, COPY the empty-example
directory into the newly created week-3
directory. Then relabel it 01_hello-world
.
Regardless of whether you are on windows or mac, your course repo directory should now look like the following;
Now that you have your repo setup for the lecture this week, lets look at what is inside the p5 “empty-example” directory.
Below, is a “tree view” of the contents of the directory.
─ empty-example/
├── index.html
├── p5_lib/
│ ├── p5.dom.min.js
│ ├── p5.min.js
│ └── p5.sound.min.js
├── sketch.js
└── readme.md
You will notice that there are 2 files in the top level of empty-example/
.
index.html
sketch.js
You will also notice, that inside of the empty-example/
directory, there is another child directory, p5_lib/
. This directory contains the p5.js library files to make everything work. These are huge files that I suggest you not open in the text editor on your computer. Instead, I want you to look at the main p5.js file over on GitHub, to get a sense of what is in it. (Do not worry about actually understanding it, I just want you to look at it to have some appreciation.)
Let’s get this all open in Atom now. You can accomplish this a number of ways. I would suggest we open our entire repository directory in Atom. You can do this by;
atom .
. (NOTE: This presumes you have installed the “command line tools” for Atom).You should now see your entire repo as a “Project” in the left bar of the Atom application. Open up the course-work
directory, then the week-3
directory, and finally the 01_hello-world
directory. Finally, select the sketch.js
file from this open directory.
You should now see a blank document, with the associated tab reading “sketch.js” in Atom.
I want you to install one more package to you Atom install at the point.
Open-in-browsers
.When the package finished installing, you may close ‘preferences’.