Buttons

Rewriten Buttons Example

The Processing and Processing.js web sites include a Buttons example by Casey Reas and Ben Fry. The Clickable package allows simplifying the code significantly because it takes care of much of the declaration, creation, drawing, and mouse click code.

This sketch uses a rewrite of the Buttons example by Casey Reas and Ben Fry. It uses 56 lines of code (excluding the Clickable library code).

The rewritten code: Buttons.pde

This sketch uses the original code by Reas and Fry. They used 212 lines of code. Part of the difference is that the way they created their buttons used more lines of code than necessary. The rewrite declares and creates the buttons in the "global" declaration section while they created them in the setup method.

The original code: ButtonsOriginal.pde

Return to the top of the page

Revised: 04/11/2014