Week 10 – Nov 6th and 8th

Tuesday Nov 6th

  • Introduction to object literals and JSON!
  • Note, if you are using a local editor like atom and want your paths to point to online instances of p5, there are links to all the p5 files here.
  • Read over the Object literal tutorial and do the exercises.
  • Sign up to Github.
  • Finish your Generative Landscape project

Thursday Nov 8th

  • Generative Landscape projects due at the start of class. Ensure you have documented your work on this blog. Come ready to present and discuss.
  • Homework:

Exercises:

Explore Darius Kazemi’s github repository of corpora. (Fork it to your github account, see the fork button at the very top right). In the data folder are a great many lists (all in the JSON format) of different categories of things. Take a look around in there!

Github lets you access the raw data of any file it hosts, so if you go to a list you like, and click the raw button, you will see the raw json. You can use the url of this raw JSON in the loadJSON function.

eg. here is the raw JSON for a list of donkey breeds:

https://raw.githubusercontent.com/dariusk/corpora/master/data/animals/donkeys.json

Or laundry care instructions

https://raw.githubusercontent.com/dariusk/corpora/master/data/instructions/laundry_care.json

If you want to use one of these files, you could use these paths that link to the file as stored on Github or you might copy the data and put it in a local .json file. Use this repository ( or otherwise) and do the following exercise:

1. Navigating JSON:

Fork this sketch to your openProcessing and do the exercises at the bottom.

2. Joke generator:

Create a program that generates knock knock jokes. At a minimum your program should generate a random reply to “Who’s there?” and create the final line of the joke. Generate 10 jokes. Don’t forget to consider fonts, colors and layout.

Extension: Using Kazemi’s files, create program that generates a different style of text. eg. you might make a cocktail recipe generator, an emergency sign generator, a weather forecast generator, etc. etc.