Smoothed Polylines
  Smoothed Polygons
  Rainbow Palette
  Hot Iron Palette


Pencil is a screen saver animation that I first remember seeing at the Mark Williams Company in the old Teletype building at 1430 West Wrightwood in Chicago. It was running on a prototype of the Commodore Z8000 PC sometime in the early 1980's with this monster monochrome monitor. It's one of the first things anyone did once they got a raster graphics display system. An on-stage demonstration of a Java version was part of Scott McNealy's keynote address at the first JavaOne conference in San Francisco.

The basic idea is to set two points bouncing around inside a window.

Then we add afterimages of the points, keeping some number of previous images of the points on the screen.

Then we connect the points into a line. This gives an effect somewhat like a pencil in free fall bouncing off the walls of a box with afterimages.

If we increase the number of points, we can connect them into a polyline or a closed polygon.

Using Tk's intrinsic spline smoothing, we can get either a smoothed polyline or a smoothed polygon.

We can make things more interesting by generating a rainbow colored spline, or the hot iron colored spline shown above.

The source for Pencil is 512 lines or about 15Kbytes of code.

Roger E Critchlow Jr
Last modified: Fri May 16 19:39:13 MDT 2003