Classic Computer Magazine Archive START VOL. 4 NO. 8 / MARCH 1990



Remember Spirograph, the game that let you generate geometric shapes through a few simple adjustments? Ian Lepore and Pete Ewing bring this fascinating concept to the ST with their program SpinWheel. Even if your talents don't include drawing, you'll still find this program easy to use and addictive. And you can save the images you generate in Spin Wheel into your favorite graphics program. Spin Wheel was written in C and runs in all three resolutions.

It's revolutionary! SPINWEEL.ARC is on Side 1 of your START Disk.

This is just one of the many attractive patterns
you can generate with SpinWheel

After running across an article in Scientific American a few years ago on the mathematics of cycloids, we decided to create a drawing program that would generate attractive geometric drawings by making a few simple adjustments. "What the world needs," we thought, "is a method of drawing these pictures that doesn't rely on manual dexterity." (Ian has none, you see.) The result is SpinWheel.

The SpinWheel concept is simple and is roughly based on the old Ohio Arts game called Spirograph. You have a fixed gear that is stationary and a rolling gear that moves. All you do is adjust the gears to generate the patterns you want and the program does the rest.

Using SpinWheel
To use SpinWheel, boot this month's START disk; the START menu program runs automatically. At the main screen, click on Prepare, then select "SpinWheel." The program will un-ARC directly onto the destination disk you specify. To run SpinWheel, double-click on SPINWEEL.PRG at the Desktop. SPINWEEL.RSC must be in the same directory. SpinWheel runs in all resolutions.

If you have your ST's color pallete set for a white background, the program will reverse the colors to provide a black background for drawing. (The colors will be restored to your settings when you exit.) The program begins in Menu mode, with a standard menu bar visible. The menu contains three selections: Desk, File and Options.

The File Menu

Draw: Starts or continues a drawing using the current gears and options. When you select this command, the program changes from Menu to Draw mode. The GEM menu bar will disappear and the drawing begins. While in Draw mode, holding down the left mouse button pops up a speed control. When the control appears, move the mouse pointer to the slider box and set the desired drawing speed. To stop drawing and return to Menu mode, click the right mouse button. (You may need to hold down the right button momentarily). A slow drawing speed helps you to stop drawing at precisely the place you desire.

New Shape: This selection starts the New Shape dialog, letting you select new gear sizes and pen position. When in New Shape mode the menu bar disappears and a group of four buttons appears in the upper left corner of the screen. The first three are radio buttons which select which piece to manipulate (the fixed gear, rolling gear, or pen.) The Done button returns you to Menu mode. The New Shape dialog is described in detail below.

Clear Screen: Clears the screen to let you draw another pattern.

Save Image: Saves the current drawing as a DEGAS or NEO file.

Load Image: Loads a DEGAS or NEO picture.

Quit: Exits SpinWheel

The Options Menu

Smoothness: Sets the spacing between dots when the image is drawn. Small numbers (less than 2) result in a very smooth image, but the drawing proceeds rather slowly. Large numbers can produce interesting results as the drawing gradually solidifies with a strobe-like effect.

Set File Format: With this option you choose whether a DEGAS or NEO file is saved.

Set Screen Access: The program, by default, uses a custom pixel plotting routine to draw the images as quickly as possible. Unfortunately, this isn't compatible with extended-resolution monitors. Set Screen Access allows you to change to VDI graphics methods, providing compatibility with non-standard display hardware.

Reverse BG Color: The best looking drawings are those done on a black background. However, a dump of the screen to the printer (using ALT/ HELP), looks best if the background color is white. This option reverses the foreground and background colors for this purpose.

Set Color Pallette: A mini control panel pops up which allows you to set the colors in the ST pallete.

Set Pen Color: Chooses a new pen color to use when drawing.

Creating A New Shape
Drawing a new shape takes several steps. Note that it is not necessary to change each of the pieces every time the New Shape command is selected. The following description assumes that all three pieces are to be changed.

Start with the Fixed Gear button selected, and hold down the left mouse button. The mouse pointer changes, and a rubber box appears which tracks the movement of the mouse. (You'll notice that this is not a standard rubber box; it is centered on the screen, rather than fixed at one corner).

When you release the mouse button, a circle is drawn to indicate the new size of the fixed gear. The size of the fixed gear always corresponds to the horizontal length of the rubber box when the mouse button was released. For example, if you drag out the rubber box to look like a tall narrow rectangle, you get a gear with a small radius. Try it, you'll see.

Select the Rolling Gear button, and once again hold down the left mouse button and drag the mouse. This time, the rubber box remains attached to the right side of the fixed gear. If you drag the rubber box to the right of the fixed gear, you define a rolling gear that travels around the outside of the fixed gear. If you drag the rubber box to the left, you define a gear that rolls inside the fixed gear. Again, when you let go of the mouse button, the diameter of the rolling gear is equal to the horizontal length of the rubber box.

The fixed gear in SpinWheel is always a "ring" type gear and the rolling gear a "wheel." You can place the rolling gear inside or outside the fixed gear. You can even place a very large rolling gear inside a small fixed gear.

Next, select the Pen Pos (Pen Position) button. When you hold down the left mouse button and drag, you will stretch a rubber-band line which connects the rolling gear to the mouse pointer. When you release the mouse button outside the rolling gear, you might think of the pen as being attached to the end of a stick which is glued to the rolling gear.

When you have set the gears and pen the way you want them, click on Done to return to Menu mode, then select the Draw command to begin the new drawing.

Tips and Techniques
It is important to remember that the Draw command starts or continues a drawing. You can mark out a shape, draw several revolutions of the gears, then suspend the drawing, return to Menu mode, change the pen color (or any other option), then resume drawing from where you left off.

If you start drawing a new shape then realize you meant to change the pen color before you started the drawing, the following sequence will straighten things out:

1) Stop drawing and return to Menu mode.

2) Select the new pen color.

3) Select New Shape, and click on Done in the New Shape dialog without changing anything.

4) Select Draw to restart with the new pen color.

By going into the New Shape dialog, you force the draw routine to plot over the points that were originally done in the wrong color. If you don't go into New Shape first, the drawing would resume from where it left off.

The Save Image and Load Image options can be used to generate interesting clip art which you can include in other programs that accept DEGAS or NEO pictures. (The speed control in Draw mode is intended to help with this; it allows precision stops while drawing.)

About The Program
You'll find the source code for SpinWheel on Side 2 of your START disk (to access programs on Side 2, see disk instructions eleswhere in this issue). SpinWheel was written in C (and a little bit of assembler), and compiled using the Sozobon C public-domain compiler and Ian's GEMFAST public-domain GEM bindings. It should compile correctly using any other compiler and bindings, such as Laser C or Alcyon C. In the source-code file main.c are some hints about compiling with other compilers.

If you program in C you'll find useful subroutines within SpinWheel's source code. Of particular interest is fastplot.c, which provides assembler code for quickly plotting pixels of any color in any resolution. The code is commented extensively and written modularly, so the subroutines can be ported to your own projects.

Pete gets credit for the math wizardry.

Ian Lepore is a Senior Operations Analyst (read: Company Technical Guru) for AMSOC a Denver firm providing computer facilities management services. Pete Ewing specializes in mathematical programming and is learning to fly. This is their first program for START.