Week 5 Class Notes

Opening Video: ?

Section One Test is Next Week

There will be a test at the beginning of next week’s class. This test will include one or two programming challenges and a written portion. The challenges will require a good understanding of the concepts introduced in the first five weeks of the class. The written portion will include questions related to javascript and p5. The test will be open Internet, you can consult any Internet references you wish during the test.

Week 4 Challenge Overview

Code Style

Poor Style

Better Style

Good Style Practices

Working with Images

Digital Images

An 8-bit RGB Image

0,0,0     255,0,0     0,0,0
255,0,0   255,0,0     255,0,0
0,0,0     255,0,0     0,0,0

p5 Image API

Working with images in javascript with p5 is pretty easy. The main catch is that you need to have things set up right for it to work on your local computer.

When working with images:

Using a Local Server

To work with images in p5 you are going to need a local web server. A web server is a application that provides web files over the Internet to Chrome. A local server is just a web server that is running locally on your computer. Your web browser will communicate with the server the same way it would communicate with a remote web server, but because both applications are on the same computer you don’t even need to be on a network for this to work.

You need a local server because Chrome expects websites to be hosted online, not on local files in your computer. Chrome will run simple projects from file://, but scripts that load external files from javascript (like images) will violate security measures in Chrome. Chrome won’t have a problem if the files are served up by the local server.

Many options for running local servers exist. Anvil is a simple OS X App that makes setting up a local server easy. Just install Anvil, tell it to serve the folder that contains your project files, and then load up your site in Chrome.

P5 Tutorial on Local Servers

Homework

Note: reworking and resubmitting the first four assignments is a great way to study.