|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Ads Donate Humor |
|
|
WShowfs.rtf - IFS fractals WinHelpThis source file is compiled by the Windows Help Compiler to produce the WShowfs.hlp Windows 3.1 WinHelp file for the WSHOWFS project. This RTF file describes features specific to WShowfs's calculations and commands. A second RTF file (sdibwin.rtf) is compiled along with this one. It describes the graphics features that are common to several of my programs. If you use Microsoft Word, these WinHelp source files are based on the helpfile.dot template, which you might find useful. WShowfs.RTF# $ K + Fractal Display Help Contents OverviewHID_OVERVIEW # $ K + Overview WSHOWFS generates and displays fractal shapes using the Iterated Function System (IFS) method pioneered by Michael BarnsleyHID_FURTHERREADING. The basic unit of activity of the method is called a transformation. A transformation is a mathematical rule that you can apply to each point of an image to generate a second image. The new image is related to the first one, since it was generated using a strict mathematical rule, but it is usually different from the first one (transformed). It may be smaller or larger, rotated into a new orientation, or moved to a new location in the plane, or any combination of the three. These three components of a transformation are called scaling, rotation, and translation. If you apply the same transformation to every point of an image, the second image as a whole will also reflect the transformation that was applied to each point. That is, if the transformation consists of a 50 percent reduction in both the X and Y values, the second image will be half the size of the original along both its X and Y axes. X and Y can always be treated separately. That is, you can scale X but not Y, or you can rotate X but not Y (which results in the new image being squished, with its X and Y axes not perpendicular to each other), or you can translate along the X axis, but not along Y. A single transformation is not enough to generate a fractal image, however. To do that, you need more than one. Your group of transformations is called a transformation set (or transform set). The method for using these to generate a fractal is: 1. Start with any point (X,Y) on the plane. The result is a fractal image, in which every component part is a smaller (and sometimes altered, though still recognizable) copy of the whole design. Even though a random number is used to choose which transformation is used for plotting any particular point, and thus the points are plotted in random order, a given transform set will always produce the same image! Using Fractal Display, you can:
All designs, whether random or from a file, are automatically scaled to fit inside the display window. The X and Y dimensions are scaled independently so that the design is centered in the window and fills it as fully as possible. Because of this, a transform set loaded from a file may be differently proportioned when displayed by this program as compared with the display produced from the same set by another program. If you want to achieve specific proportions for a design, you can size and proportion your display window until the image has the proportions you want. Fractal Display must be run under Windows in full color (24-bit, 16.7 million color) mode. As new drawing windows are opened, the program automatically reduces the number of points each window draws with each pass through the drawing routine to try to keep system slowdown within an acceptable range. In WSHOWFS.INI, the entry DRAWCOUNT specifies the number of plotted points each pass if there is only one drawing window open. You can increase this number if your system is fast enough to handle the extra drawing without too much slowdown. You should try to keep system slowdown minimal. If the slowdown is excessive, it is possible for mouse events to be logged to the wrong window, which can produce unwanted effects. For example, dragging the mouse to mate two PFS sets could instead result instead in an icon in Program Manager being dragged to a new location if the Program Manager window was behind WSHOWFS at the time of the drag, and if the drag was incorrectly attributed to that window. For mating runs, it is safest to minimize all other applications so only the desktop is beneath this application. (No longer necessary. Drawing is temporarily stopped while selecting parents.) Sets with many transforms, even with duplicate transforms, result in more interesting coloration. So does use of reflection (e.g. -100 100 0 0 0 0 20), since it causes regions to overlap, mixing the colors. # $ K + Transform Set File Formats (.PFS and .IFS) Both types of files are text files, and can be edited with any text editor. If the program cannot create a valid IFS or PFS set from the data in a file, it generates an error message when it attempts to load the file. (Unfinished note:) Numbers that specify percentages can exist in a file either as decimals (e.g. .25) or as whole numbers (e.g. 25). As long as you are consistent within a file, the program can usually interpret the file correctly. However, only 100 can mean 100% scaling (1 is interpreted as 1%). .PFS Files The PFS format specifies a transformation using polar coordinate terms, rather than rectangular. The P stands for Polar. The PFS format is different from and considerably more understandable than the more frequently used IFS format because after some practice it is possible to look at a PFS transformation and visualize what the effect of the transformation might be; this is usually not possible with an IFS file. Structure of a typical .PFS file: 3 - The first line is the number of transformations in the set You can put comments about the file (such as what it is supposed to display) on lines after the last data line. The constants ABCDEFP above are the factors for scaling, rotation, translation, and probability for each transform in the set, as follows: Scaling
Rotation Translation
Probability All the numbers are written as integers (that is, no decimal points). Valid numbers in each category are as follows: Scaling Whole percents : -99 to +99 As an example, consider the following transform set in PFS form: 1 To compute a new point using this transformation, the original X is multiplied by 50%, the original Y is multiplied by -70%, X and Y are both rotated 90 degrees, and the result is moved -10 units along the X axis and +20 units along the Y axis. The probability that this transformation will be chosen (since it is the only one) is set at 100 percent. When the scaling factor is negative, the image is flipped over the corresponding axis, so that it creates a mirror image of itself. This complicates matters, because it seems to cause the rotation angle to be interpreted backwards. The probabilities for all the transforms in a file must total 100, but it is not necessary that all the transforms have an equal probability of being chosen. Changing the probabilities does not change the shape of the image produced, but it changes the densities with which various parts of the image are filled in. If two transforms have probabilities 75 and 25, the first will be chosen 3/4 of the time, on average, and the second only 1/4 of the time. Note 1: .IFS Files The numbers that go into an .IFS file are calculated from the scaling, rotation, and translation factors that go into a .PFS file, but beyond that, most of the individual numbers have no easily-describable meaning. Here is the structure of a typical .IFS file: 3 - The first line is the number of transformations in the set You can put comments about the file (such as what it is supposed to display) on lines after the last data line. It looks exactly the same as a .PFS file, but the resemblance ends there. The factors RSTUEFP above are calculated from the polar variables above as follows: R = A * COS(C) It is not easy to look at an IFS transform and discern what effect the transformation might have on an image. You apply an IFS transform to calculate a new point (newx,newy) from the previous point (x,y) as follows: newx = Ax + By + E All the numbers in an IFS file are integers. It matters little what constitute valid numbers for the RSTU variables, because designing a fractal in IFS form is virtually impossible. Killer Transform Sets (so-called because they kill the program with a math co-processor floating point error) Some PFS or IFS transform sets tend to produce math errors, usually numbers too large (towards plus or minus infinity) or too small (towards zero) for the computer to handle. The program tests a number of points before starting to draw an image. If it detects that the current set would cause such a math error, it generates an error message and refuses to calculate and display the image. Sets containing only 1 transform are particularly prone to generate these errors. # $ K + File Menu Commands New Opens a new window and begins drawing a new random design in it. Open Allows you to specify one or more files to display. Opens a new display window for each file. You can also specify filenames on the command line when you start the program. For example: WSHOWFS.EXE 1.PFS 2.PFS... You can also open files using Drag and Drop from FileManager. In order to open a new window for each file, you must drop the files (by releasing the mouse button) with the cursor NOT INSIDE the drawing area of any open drawing window. That is, the existing drawing windows must be arranged so that some background area (not containing any windows) is visible. If you accidentally drop the files within a drawing window, the files will be added to that window's own list (see File | Load List, below.) Load List Allows you to specify one or more files to display. Files are added to the display list (queue) of the currently active drawing window. Subsequently, each File | Next command begins drawing the next file in that window's list, replacing the previous design displayed in that window. That is, instead of opening a new window for each file in the list, the files from the list will be displayed sequentially in a single window. You can also add files to a window's list using Drag and Drop from FileManager. Be sure to drop the files (by releasing the mouse button) while the cursor is INSIDE the drawing area of the window that should receive the files. (See also File | Open, above.) As a practical matter, File | Load List might only permit you to add a few files at a time, because there is a limit to the amount of text the dialog box can return. There is no such limit if you use the Drag and Drop method, which is better. Next or Random Abandons the current design in the currently active window. If the window has one or more designs waiting in its display queue, it moves on to the next one in the queue. If the queue is empty, it generates a random transform set using the parameters that apply to random sets (number of transforms, XYSameRotation, XYSameScale) and begins drawing the resulting shape. Edit Allows you to edit this window's current transform set as text in an editor window. If you exit the transform editor with the OK button, the program immediately starts drawing the new design. Save Save the current transform set to disk in text format as an IFS or PFS file. Allows you to specify a filename. If the current design is Untitled (not already from disk), the suggested filename in the SaveAs dialog is the next sequentially numbered filename available in the current disk directory. The names begin at 0.PFS, and increase to 1.PFS, 2.PFS, etc. The program will not overwrite existing files. If 0.PFS exists, it tries 1.PFS, and so on, until it finds the first unused filename. Save as .BMP Saves the currently-displayed design (in the size it occupies in the currently displayed window) and its color palette to disk as a .BMP file. You can then import the file into a bitmap editor. To create a design with a specific size or proportions, size the display window as needed, wait for the design to be sufficiently filled in, and then Save as .BMP. Exit Closes all open files and exits the program. The name of the currently logged disk directory is saved to WSHOWFS.INI, so that it is your default starting directory the next time you run the program. # $ K + Colors Menu Commands Load .MAP File Loads a FRACTINT-compatible .MAP file for use as the color palette. The program maintains a 256 color palette, and can use up to 256 colors from the .MAP file. The .MAP file should not have any color duplications in it. Most of the Fractint .MAP files don't work well. Monochrome mode only uses one color in the palette, anyway, and ColorByTransform only uses the first few, which are usually similar to each other. That leaves ColorByHits mode. Unfortunately, the .MAP files tend to have lots of duplicate colors, and it's important for this program that colors NOT be duplicated. The hit count for a pixel is inferred by searching for its color in the palette. If it has color #10, then the program knows it's been hit 10 times. the search stops when the first occurrence of a color is found, so if a color is duplicated, the highest a pixel can reach is one less than the second occurrence. It will then cycle in the area between the 2 occurrences. Randomize Fills the color palette with completely random colors. Set Monochrome Color Displays a dialog box in which you can specify the color to use when drawing in monochrome mode. It also automatically switches to monochrome mode and turns AutoRandomizeColorsHID_VIEWMENUCOMMANDS OFF, so that the color you selected remains the drawing color until you change the color or change the point coloring mode or turn AutoRandomizeColors on again. Rotate Forward, Backward Rotates the color palette either forward or backward. Not useful. Editing Colors with the Mouse You can redefine any color displayed on the screen. Position the cursor over an example of the color you want to change, and Right-Click. A dialog box will open in which you can specify a new color to use. It can be difficult to position the cursor over a dot of exactly the color you want to edit, so be sure to check the color initially displayed in the dialog box to make sure it is the right one. # $ K + Genetics Menu Commands Select As Parent You can "crossbreed" 2 displayed images to produce children derived from them. There must be at least 3 windows open. You select two as parents. The remaining one or more will become the children of the parents, drawing images derived from those in the two parent windows, as described below. Only windows drawing random designs can become children. That is, after mating, the two parent windows will continue drawing their designs (unchanged), and any windows drawing designs loaded from files will also remain unchanged. Any remaining windows (those drawing random images) will abandon their current designs to become children of the parents. Instructions: 1. Open the total number of windows you want displayed. 4, 6, 8, 9, 12 work well. 2. Either open files in them or start them generating random images. When you see two designs that you want to combine, 3. RightClick in the window you want as the first parent, and while holding the mouse button down, drag the cursor into the window you want as the second parent. Each time a parent is selected, you will hear a sound that confirms it. After the first parent has been selected, the cursor turns into a cross (+) to indicate that the first parent has been selected, and the second is needed. Alternatively, you can RightClick in the first window (and release), then RightClick in the second window (and release). Or, choose Genetics|Select As Parent, Or press the parent selection toolbar button. 4. As soon as both parents have been selected, all eligible child windows (as described above) will start drawing new designs created from the chosen parents. How the children are created: All the transforms from the 2 parents are combined into one large set. Then, because such large sets are seldom interesting, a random number of the transforms are deleted, leaving at least 2 transforms in the set. Lastly, if you have specified Mutate When Mating, ONE of the numbers in ONE of the sets is randomly changed. The mating procedure does not automatically change AutoAbort settings. Any window, including a parent window, with AutoAbort set TRUE may AutoAbort at any time except during parent selection. You will note that during parent selection, all drawing in the windows is also temporarily turned off. Because the drawing places heavy demands on system time, turning it off helps ensure that mouse clicks are processed properly. (You can also use parent selection as the method to turn drawing off for any other reason, such as to make your computer temporarily more responsive while you switch to another application. To turn drawing off, select one parent, but not a second parent. To turn it back on, either select a second parent or Zero Both Parents. See below.) Zero Both Parents Under certain circumstances, the program can become confused during parent selection, and may indicate that you have selected 2 parents when you thought you only selected 1, or it may continue to display the cross cursor when it should not. If the program seems confused, reset the parent selection process by selecting Genetics | Zero Parents, or the Zero Parents toolbar button. This will deselect any selected parents and restore the normal cursor so you can start fresh. You can minimize the chance of problems by clicking only in windows you intend to be parents, and by only dragging into or out of windows you intend to be parents. # $ K + View Menu Commands When you first start the program, you can simply press <Enter> at each of the options dialog boxes. The default settings have been set automatically, and you do not need to override them until you are more familiar with the program. If you don't want to set any options whenever a new window is opened, turn the View options at Startup checkbox OFF. At startup, if the program has no files to open (such as from FileManager), it begins with 4 random windows that demonstrate the different characteristics of the 4 possible XYSame settings, described below. Options (all)... (Dialog Box) Allows you to set a number of parameters simultaneously. Changes to parameters that define the characteristics of new random sets do not take effect until the next random set is generated. Most of the checkboxes on the lefthand side set the same parameters that you can set individually in the View Menu. See below. Additional settings: XY Same Rotation When ON, random transforms are generated such that the X and Y axes are always rotated by the same amount, and are therefore always perpendicular to each other. For example, a plus-sign turned 90 degrees remains a plus sign. This tends to generate more regular designs. When OFF, the X and Y axes may be rotated by different amounts. In this case, a plus sign rotated may wind up looking like an X, which is not just a plus sign rotated: its axes, rotated by different amounts, have become skewed from each other. This option tends to generate more wild, irregular designs. XY Same Scale When ON, random transforms are generated such that X and Y are always scaled by the same amount. The resulting designs tend to be quite regular, since all the smaller pieces have the same X/Y proportions as the whole design. When XYSameRotation and XYSameScale are both ON, the designs have the maximum amount of regularity, since every small piece is in all respects an exact and proportionally scaled copy of the whole. If you do not specify any files on the command line when you start WSHOWFS, the initial display contains 4 windows, so that you can see the different types of designs produced by each of the 4 different possible combinations of the XYSame values. Point Coloring Method Number of hits (ColorByHits) Each time a point is hit, its color is incremented one step further into the palette. Transform Number (ColorByTransform) A point is colored according to which transform generated it. The color used to plot the point matches the text color of that transform in the data area. Monochrome (Monochrome) Only one color is used for plotting. # Transforms Specifies the number of transforms that each random set will have. 4 is about the maximum that ever works well. If it is set to 0, each transform set will have either 2 or 3 transforms. Duplicate Limit If Auto-abort TestsHID_VIEWMENUCOMMANDS is ON, and this number of consecutive points have all been hit previously, the program will consider the design finished, and will move on to the next one. Increasing this number keeps designs on the screen longer, giving you more time to decide whether to save each image. Use Sound (Beep) Toggles the use of sound in the application (not much used, anyway, however). When points in a display repeatedly would fall outside the screen boundaries, the design aborts and the PC speaker beeps once to let you know that that was the reason, rather than because the duplicate points limit had been reached. Show Equations Toggles whether to automatically display the data area in the top left corner of the window. The data area shows the number of transforms, the associated filename, the transforms themselves, and the number of points plotted. Changes to Show Equations might not take effect until the next time the screen is erased. Upside Down Turns the design upside down on the screen. Auto-abort Tests When a random design is being drawn, the program keeps track of how many consecutive times it has gone to set a point and found that the point has already been hit at least once before. If it hits enough of these points in a row (the default duplicate limit is 1000, but you can set it in the Options dialogHID_VIEWMENUCOMMANDS), it considers that the design is sufficiently well filled in, and is finished. If Auto-abort Tests is ON, it stops drawing the design and moves on to a new one automatically, as if you had issued a File|NextHID_FILEMENUCOMMANDS command. If the finished design was a random one and you have not used SaveHID_FILEMENUCOMMANDS to save it by the time it moves on, it will be lost (overwritten by the new one). The program also tests for whether plotted points fall outside the display window. A number of points can fall outside the window without aborting the design, but if the design seems to be steadily growing beyond the window, this is another condition that will cause the program to abort the current design and move on to the next one. When Auto-abort Tests is ON, it allows you to sit back and watch consecutive designs without having to do anything. Turning it OFF allows a design to be drawn until you decide it is done. It can also be used to give yourself some extra time to decide whether you really want to save a particular design. ColorByHitsHID_VIEWMENUCOMMANDS mode generates the most colors when Auto-abort Tests is OFF, because the colors take some time to cycle through the palette. When a file is loaded from disk, Auto-abort Tests is automatically turned OFF, so the file continues to draw until you stop it. When a new random set is created, Auto-abort Tests is automatically turned ON. If you turn it OFF during the display of one image (so that it draws until you stop it), the next random image will automatically turn it back ON. AutoRandomize Colors When ON, the palette is automatically filled with random colors before every new design. When OFF, the palette stays the same. Show Number of points For fastest drawing, the number of points calculated and plotted is not automatically displayed. Each time you issue the Show Number of points command, the data area, with the number of points plotted so far, is displayed (only) once. (Note that the Show Equations toggle for automatic display of the data area is not affected.) # $ K + Designing Images When designing a shape, the X and Y scaling occur (in effect) AFTER the rotation, and remain screen-relative. That is, if the original WIDTH is X, and you want to rotate the shape 90 degrees and make it skinnier by half, it's Y that you scale by 50%, because after rotation the old width is now its height. The automatic scaling of the image to fill the screen can interfere with designing a new image: it's stretched in the 2 directions independently to fill the screen, so changes you introduce to alter the shape may be undone by the stretching. But it can work for you, too: you can reshape the window to squish the image however you want. The shape displayed may not be exactly the one specified by the transform set (as used raw), but you get the flexibility of shaping that you might want for pasting the image into a bitmap editor, etc. # $ K + For Further Reading Books: Magazine Articles: Computer Programs: |
|
|
|
|
|
|
|