Lines
By Ali Ozer
Updated for 2.0 by Jayson Adams
Updated for 3.0 by Ali Ozer

Overview

Lines draws a number of connected lines whose endpoints bounce around randomly within a view.  The slider regulates the number of endpoints (you can select from 2 to 20).  Lines uses PostScript user paths to speed its drawing.

Theory of Operation

The LinesView maintains an array of points and their velocities.  When you press the ªGoº button, the LinesView starts a timed entry which calls the animate method as fast as possible.  The animate method repeatedly takes each point and moves it according to its velocity (changing its velocity if it hits a side).  It then uses PostScript user paths (via UserPath.[hm];  see below) to draw lines between the points.

UserPaths made Simpler

The code in UserPath.[hm] makes user paths easier to use.  Instead of having to allocate space for the points and operators, maintain the bounding box, etc., you create a UserPath, add points to it, and send it to the window server.  The UserPath functions construct the userpath, allocate more memory for a UserPath based on how many points you've asked it to contain, adjust the bounding box to encompass all points, etc.  You can use UserPaths in your own code by copying UserPath.[hm] into!0Rr project directory and reading the beginning of UserPath.h.