CODE REPOSITORY
Processing
Just released!

COLLISION DETECTION FUNCTIONS - v0.9
A set of functions to do basic 2d collision detection in Processing
While some tools already exist, like the excellent Box2D, the source code is not easy to understand and the implementation is a bit complex. Other examples (equally great), like the line-line collision in the toxiclibs collection, use vector math which isn't great for us "creative programmers" (ie: those like me who got bad grades in high school math).
Instead, these tools can be used as simple, one-line commands to determine whether two objects have collided. Designed for simple games and interactive systems, they are intended to be building blocks for larger projects.
View the project and download the source code on Google Project Hosting
GENERAL SNIPPETS

- Create Video with Processing and ffmpeg
Runs ffmpeg (the open-source, command line based video utility) in Processing to create videos from still images, doing so very quickly; great for writing custom video compression algorithms or working with non-realtime video creation
[ see here for a post on how to set up ffmpeg on Mac Snow Leopard ] - Test for Decimal
Test for whether a number needs a decimal place - example: you want to display "1" next to "3.5", but don't want "1" to
show up as "1.0" - Download File from URL
Download files from the web (great for data visualization projects, HTML scraping, etc) - Read Binary File
Set up to read .wav files; can strip the header and read raw data in
Useful for getting audio sample values, pixel data, and other non-human-readable files
- Area Proportion Calculator
Given an initial dimensions and a target area, returns the resulting dimensions
Formula: long side = sqrt(Target Area / (Initial Long Side/Initial Short Side)) - Change Case of String
Converts a letter (stored as a string, not a char) to the opposite case - Create A New File
Make a new file (.txt or .dat likely most common) - Run Unix Commands (and Bash Scripts)
Run Terminal commands and Bash scripts from within Processing; when running commands like sorting or combining files, using these commands will be considerably faster
TEACHING SKETCHES
- Array for Multiple Object Movement
Store position and direction for multiple objects in an array; great for basic game structure - Ball/Ball Collision Detection Using the Pythagorean Theorem
Prevents errors that bounding box collision detection introduces - Ball/Multi-Ball Collision Detection and Click-and-Toss
Click and toss a ball, detect collision with multiple balls - Basic Grid Structure
See pixels labeled onscreen; great for those less comfortable with x,y coordinates - Game-Based Collision Detection and Font
Simpe shooting game with title screen - Incremental Movement and Keyboard Interaction
Use arrow keys to move a ball around the screen - Point/Ball Collision Detection
Most simple collision detection - Translate and Rotate (and Some Trig)
Rotate an arrow and shoot in that direction (demonstrates basic trigonometry in Processing) - Reading CSV Files (zip archive includes a sample CSV file)
Read a comma-separated-values (CSV) file and visualize the data using a BufferedReader; a great first step for data visualization and sonification projects
[ pde file only ]
RANDOM and INTERESTING
- Basic Data Visualization (zip archive includes the map image and fonts)

Download and visualize USGS earthquake data from a comma-separated-values (CSV) file
+ View the visualization file and download function
- Pythagoras Tree

A classic fractal built from recursively smaller squares; interactive using the mouse
+ Also, a non-scaling version that uses 30-60-90 triangles
+ ...and a not-quite-working version that has some interesting results