Spirograph v.1.5
Alexey Burshtein aka "hitech"
hitech@abee.dyndns.org
 

Changes from v1.2B to v1.5

Contents


Changes from v1.2Beta to v1.5
    What's new in Release 1.5
Contents
    Come on... You're reading it!!!
About the Program (and the author)
    Examples of what the program can do. 
    Short info about what the source code may demonstrate. 
    Info about the author.
General Description
    About the toy "Spirograph" - what does this program simulate? 
    2-gears model.
User Interface
    Explanation of all the controls and features you may find. 
    Of particular interest are the following: 
        "Fixed angle" checkbox
        Pen Width
        "Third gear" checkbox - explaining 3-gears model.
        User menus explained
How do I save the drawing I created?
    So, you've created the spiral of your dreams. How do you save it?
In planned releases
    What I am coding in while you're playing with my toy.
Thanks to:
    Partial list of those I'd like to thank.

About the Program (and the author)

Main screen of the application.
This program is a simple toy I've created in my spare time as my first "real" BeOS GUI application.

It demonstrates working with various BViews - especially BBitmap and BMenu, threads, controls, some messaging techniques and two interesting functions - Spirograph function (named in source code just "function") and Euclide's algorithm for finding GCD of two integer numbers (named GCD).

About the author: My name is Alexey Burshtein, my nickname since 1997 is "hitech", and I'm a 2nd year student for B. Sc. in Computer Sciences at the Technion - Israeli Institute of Technology, working as a developer for IBM Haifa Research Labs.
 

General Description

2 gears explained
    Spirograph is a toy which includes a plastic ring and a plastic disk - the disk is smaller, it is placed inside the ring and is always in touch with the ring. The disk has a hole, not in its center. A pen is put through this hole.  Then the user applies some force onto the pen, and it starts to move. Guided by the position of the hole, pen leaves on paper beautiful spiral figures, which are guaranteed to be of finite length (finite they are, but some radiuses of the ring, the disk and position of hole inside the disk may result in the curves being REALLY long - though still finite).

    Spirograph was invented in 1965 by a British military engineer and won the title of the best educational toy 4 years in a row - 1966-1969.

    The toy is so exciting and beautiful that I decided to create its GUI equivalent, for the most magnificent OS I know - the BeOS!
 

User Interface

    Though it is pretty self-explanatory, I believe an additional explanation will be good.

Color - the color of the curve to be drawn. (Note that "Rainbow" and "Random" will be implemented in future versions).
Pen Width - allows to control the width of the curve. You will find yourself rarely using width other then 1 pixel, because else the lines on the resulting drawing may appear too close to each other and you wouldn't see blanks between them, but you may use it to create drawings like this:

Using different pen widths allows drawing of a curve inside a curve.
(Here I consequentially reduced pen size by 2 pixels each time, choosing another color but leaving other parameters untouched).

Main Radius - radius of the ring. It is the biggest radius of the three. In my program it must be between 2 and 250 pixels, if it is not - it will be automatically changed to the closest limit. (Note that if you specify "Main Radius" = 2, it will cause "Internal Radius" to be 1 and "Hole Position" to be 0).

Internal Radius - radius of the disk which is placed inside of the ring. It must be at least 1 and at most "Main Radius"-1. (Note that "Internal Radius" = 1 will make "Hole Position" = 0, and you'll receive one dot in the center).

Hole Position - distance between the center of the disk and between the hole. It must be between 0 and "Internal Radius"-1. (Note that "Hole Position" = 0 will always draw a circle).

Fixed angle - as I mentioned above, process of drawing, while ALWAYS finite, may be sometimes quite long and very resource-consuming. As soon as I don't use threads in this application (yet), during this process you'll feel your system is stuck. IT IS NOT!!! The total amount of circles of the disk inside the ring needed to complete the figure depends on sizes of the disk and of the ring. If they have nothing in common (i. e. 250 and 139), the drawing may take up to tens of seconds.
    If this option is CHECKED, the drawing will always stop after the disk have performed a turn of 500 degrees, which is perfectly enough for most figures.
    If this option is NOT CHECKED, the drawing will continue until the figure is complete, which may take much longer time, (but may take also less!)
    Note that both of these options are useful to create beautiful pictures:
 

With "[x] Fixed angle" CHECKED, the following drawing took 1 second:

With "Fixed angle" NOT CHECKED , the following drawing took 51 seconds:


Third gear and 3rd Gear - these controls allow to draw even more spectacular curves, which are impossible to create with plastic toy. If "[x] Third gear" checkbox is checked, another gear (which radius is controlled by the "3rd Gear" text box) is placed into the ring, and the disk revolves inside that third gear. The direction of rotation of the third supplementary gear is opposite to the direction of rotation of the disk with hole. (Compare the pictures "2 gears explained" and "3 gears explained").

3 gears explained

Note: creating a curve in three gears mode is not much different from creating one in two gears mode. Therefore all said about "Fixed angle" checkbox applies to these new curves as well. Try choosing a prime number as the internal disk radius, uncheck "[ ] Fixed angle", check "[x] Third gear", click "Draw!" - and you may leave computer alone and get yourself a cup of coffee. A big cup of coffee. A bucket of coffee.

Examples:

With "[ ] Third gear" NOT CHECKED and "[x] Fixed angle" CHECKED, the following drawing took about 1 second:


 

With "[x] Third gear" CHECKED , and "[x] Fixed angle" CHECKED, the following drawing took about 1 second as well:

With "[x] Third gear" CHECKED and "[ ] Fixed angle" NOT CHECKED, the following drawing took 48 seconds: (notice how many lines from the full image below are missing on the partial image above)

Draw! - will draw the curve.
    Any new curve will be placed on the top of current drawing. It allows to create colorful spiral views, like the one shown at the first screenshot. Order of the curves may be changed later.

Clear - clears the drawing area.

Menus explained:


File menu:
    As you may guess, this menu contains options which will allow you to work with files.
Clear - (Alt+N) - clears the drawing, erasing all your unsaved work.
Open as background... - (Alt+O) - allows to open an image as a background. Any format for which you have a translator may be used.
Save As... - (Alt+S) - allows to save your drawing as an image file - in any format you have translator for.
Page Setup - (Alt+G) - not implemented yet.
Print... - (Alt+P) - not implemented yet.
Quit - (Alt+Q) - exit the program.
Layers menu:
    This menu allows to play with layers. Its main function now is reordering of the curves in the drawing and deleting individual curves, but in following releases its functionality will be enriched by additional features, allowing, for example, to hide a curve from a drawing (without deleting it) and to add it to "favourites".
    In the beginning the only option in this menu is the background. It cannot be moved higher or lower, it must remain on the bottom of the drawing (since it's background :-) ), therefore all ordering options for it are disabled. Though, you can still use this menu to add or to remove the background.
    As you add curves, they will be placed on top of the current drawing, and corresponding submenus will be added to the bottom of menu "Layers". Name of added item will be name of the color you've used to draw the curve. The last option on menu "Layers" is the layer which is currently on top. Since it's already on top, it can be moved only backward: Send backward moves the layer one position backward, Send to back moves it to be the lowest possible layer (placed immediately over the background). For every other layer, the following options are appliable: Send forward (moved one position forward) or Send to front (the corresponding curve will be placed on top of current drawing). Delete layer removes the layer.
Background menu:
    This menu controls the background, and may be used to change the background color (solid grey, by default) or to add / remove a background image. The image will be resized to 500 x 500 - this is the dimentions of the drawing area.

How do I save the drawing I created?

    You have several options to save your creations.
    First of all, you can just drag the picture you've created to the Tracker. It will save the picture under name "Spirograph Bitmap", in BMP format.
    Second of all, you can use the menu "File" > "Save As...". It will open a standard BeOS File Saving dialog, where you can not only choose the place to store the picture but also the format.
    If you want to edit the saved drawing before use, I suggest saving it in "BMP" format first, which, though very space-consuming, maintains colors very accurately. After you edit the picture, you may save it in any other format, and my suggestion is PNG which will not cause sharp color changes to blur like JPEG does (for example of bad screenshots see the screenshots above - they're JPEGs).
 

In planned releases:

1. Implementation of the custom and "Rainbow" curve colors.

2. Anti-aliasing for feeling of the smooth curve.

3. Ability to resize the window. (Shall I shrink / stretch the existing drawing then?)

4. Ability to specify the center for the next drawing.

5. "Favourites" menu.

Not all these features will be implemented in the following release - this plan is for several releases...
 

Thanks to:

1. Kevin H. Patterson - for creating the "Skeleton" application (available from BeBits), which saves a lot of time for the coder!

2. Unknown inventor of the original, plastic Spirograph.

3. Anyone that will compile this application for PPC.

4. "www.qube.ru" stuff for hosting the BeOS-related backgrounds I use - see a part of it in right-upper corner of each screenshot? :-)

5. You - the user of this application!