Converted C++ program to Processing sketch.