[comp.sources.amiga] v90i101: IFS 1.4 - an iterated function system viewer, Part02/03

Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (03/07/90)

Submitted-by: fullmer@alfalfa.sps.mot.com (Glen Fullmer)
Posting-number: Volume 90, Issue 101
Archive-name: applications/ifs-1.4/part02

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 3)."
# Contents:  ifsout.doc source/gadmsg.c source/getfile.c
#   source/ifsout.h source/makefile source/vectors.c
# Wrapped by tadguy@xanth on Tue Mar  6 17:38:05 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ifsout.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ifsout.doc'\"
else
echo shar: Extracting \"'ifsout.doc'\" \(8551 characters\)
sed "s/^X//" >'ifsout.doc' <<'END_OF_FILE'
X
X
X
X
X
X
X                            AMIGA IFSOUT Version 1.4
X
X                       An Iterated Function System Viewer
X
X              Released to the public domain by the Software Glen Co.
X                                   
X
XINTRODUCTION
X------------
X
XIFSOUT graphically displays iterated function systems and allows the 
Xuser to interactively create the affine functions that define such
Xsystems.  An IFS can represent complex pictures very compactly.  Simple
XIFSs can describe an infinite number of different and interesting fractal
Xdisplays.  Some of these pictures are remenisent of plants, ferns,
Xbushes, trees, snails, shells, sunsets and other natural objects, plus
Xa number of other interesting patterns. Included with the program are a 
Xnumber of displays that the author and others have discovered.  These are in
Xa directory named coors.
X
XWhat is an iterated function system (IFS)?  An IFS is a set of functions 
Xthat define transformations on a Cartesian space.  Each of these functions 
Xis a rule of affine transformation.  An affine function has the form of:
X
X                  W(x,y) = (Ax + By + E, Cx + Dy + F) 
X
Xwhere:
X
X    A,B,C,D,E,F are real number transformation coefficients.
X
XSo an affine function maps each point in the Cartesian Space to another 
Xpoint in the Cartesian Space.  To compute an IFS image each affine
Xfunction is randomly applied to the last computed point.  This process
Xis repeated over and over, resulting in a picture of the IFS as those 
Xpoints are displayed.  
X
X
XTHE PROGRAM - TUTORIAL
X--- -------   --------
X
XIfsout is simple to use.  To run ifsout, just double click on the 
Xifsout icon, or type ifsout in a CLI shell (stack should be > 30000).  
XIfsout takes no arguements.  Ifsout creates its own screen and begins 
Xto display a default function, a small flower.  Before starting, you 
Xshould know how to get back to the previous screen (usually the Workbench).  
XTo do so, use the Project Menu and click on the "Back to WB" box There 
Xare no Front/Back gadgets, but there is a hidden Close gadget in the 
Xnormal left-hand corner.  It almost goes without saying, to quit, click 
Xon the "quit" box in the Project menu.  
X
XTry some different functions.  Use the Project Menu and click on the 
X"Get IFS" menu.  This will bring up a file requester like window to allow
Xselection of a number of "coors" (IFS coordinate files) files.  No, it 
Xhas no relationship to the beer!  Thanks goes to C. Heath for the
Xfile browser requester.  It expects to find a coors directory on the 
Xcurrent default device. (i.e. if you started ifsout from RAD: it would 
Xexpect to find a coors directory in RAD:)  If there is no directory 
Xthere you will get a "Wrong Diskett?" message.  If this happens, 
Xjust click on OK and type in the path of your "coors" directory in the 
XGet File Requester string gadget. Included with this distribution is a 
Xcoors directory with all the IFSs in separate files.  
X
XThe displaying of the transformation numbers (those are the coefficients 
Xof the functions) can be toggled by clicking on the "Numbers" box 
Xin the "Control" Menu.  The eight numbers displayed for each affine 
Xfunction are:
X
X            function number, A, B, C, D, E, F coefficients, percentage
X
XThe coefficients are the ones in the above defined affine function.  The 
Xpercentage is the probability that the function will be randomly chosen.
XThe sum of all the probabilities should total 1.00 or some functions
Xwill not get exercised as they should.
X            
XTry to change the function using the transformation boxes.  Click on the 
X"Boxes" box in the "Control" Menu.  This will bring up a number 
Xof boxes.  Each box represents a transformation function.  One can change 
Xthe function by grabbing a corner of any box.  Note:  If two boxes' 
Xcorners are in the same position as the "selected" function (highlighted 
Xin white) will be moved.  One can change the "selected" function by 
Xclicking the left-mouse button away from the boxes when the boxes are 
Xshowing.  
X
XNotice that the corner with the small box control the E and F coefficients 
Xof the function, the opposite corner controls a combination of the A and D
Xcofficients, the near corner (the one with the small box) controls 
Xa combination of A and C coefficients, and the other corner (the one 
Xopposite of the small triangle) controls a combination of the B and D 
Xcofficients.  The small box is used to determine the orientation of 
Xthe transformation.  The program can display a IFS with 25 or less 
Xaffine transformations.
X
XTake a look at Sierpinski's Triangle by selecting the "Get IFS" menu 
Xfunction and selecting sier.coors file.  This function takes three
Xtransforms.  As you can see the images look as if they are "developing".
XSome images look better if they "cook" longer and other look best when
Xthey have only "cooked" for a short time.
X
XSometimes the function might disappear from your view as you are 
Xmanipulating them.  This is because the coefficients can also change
Xthe location of display.  To get the image back into a viewing position
Xselect the "Zoom To Fit" box in the Functions menu.  This not only centers
Xthe image but sizes it to about 85% of screen size.  This function
Xcan also be used to make a very small/large image larger/smaller.  Also
Xin the "Functions" menu there is another to contol the scale of the
Xdisplay.  It is called "Zoom Out X 2" and should be self-explainatory.
X
XTry some of the miscellanous functions.  If you have received the "paid-for"
Xversion you can save the functions that you create.  To save your function
Xclick on the "Save IFS" box in the Projects menu.  Your function will
Xbe saved with the name you specify.  Another toggle allows you to create
Xa white background.  You can also get a new function.  The coeffiecents 
Xof the new function are set to A, D, = 1 and the rest = 0.  This does not 
Xeffect the outcome of the current IFS except to add a new color and to change
Xthe percentage of the functions fo the IFS display.  Notice that each 
Xaffine function has its own color.  You can change the color of the 
Xfunctions displayed by clicking the left mouse button when the boxes are 
XNOT displayed.  The colors are selected at random. 
X
XThere is also a pause toggle.  IFSOUT program is rather compute intensive.  
XThe pause toggle allows the program to go to sleep until it is toggled again.
XThis allows the processor to do other things quicker (like capturing the 
Xscreen with any of the screensaving programs).  NOTE:  BE CAREFUL WITH THIS 
XSWITCH as it makes the program look dead and unresponsive to any requests 
Xexcept some menu selections (like the toggle itself and the QUIT funciton).
X
XAnother way to change the coeficients is by the use of the "Adjust
XFunctions" requester which can be found in the Functions menu.  The Adjust
XFunctions requester consists of four areas of control.  
X
XThe first method of control is the current function's coeficients.  These 
Xare changeable.  You can request additional functions by typing in a 
Xfunction number (WN) lager than the current number of functions.  If you 
Xtype in a function less than the current number of functions, it will give 
Xyou that function.
X
XThe second area of control is the horizonal slider gadgets next to the
Xfunction number, coeficients and percent text input areas.  They also 
Xcontrol the same functions as the text input areas.  To change a function
Xnumber just click on either side of the slider.  This slider does not
Xallow you to add additional functions but is very useful in tracking down
Xa function (by number) quickly.
X
XThe third area of control is the Zoom Slider.  It allows you to Zoom in
X(down) or out (up) a particular IFS.
X
XThe fourth area of control is the Positioner Gadget.  This allows you to
Xposition the current IFS on the screen.  Sometimes when you are Zooming
Xinto the function it changes the center.  This allows you to center it
Xto your preverance.
X
XA tip:  If you have the version that allows saving IFSs you can create
Xa directory named coors in your RAD or RAM disk for rapid saving of IFS
Xfunctions.
X
XTHE CHALLENGE
X--- ---------
X
XGet the file glen.coors.  Notice that I have defined my name as an IFS.
XNot a real easy task, but as you can see it can be done.  Can you create
Xan IFS for your name?
X
XI would also like to hear from you if you find any new and interesting
XIFSs.  My email address is fullmer@alfalfa.sps.mot.com.
X	
XI hope you have as much fun with this as I have.  There would probably 
Xbe many more program features if searching for new IFSs wasn't so 
Xdistracting!  Enjoy.
END_OF_FILE
if test 8551 -ne `wc -c <'ifsout.doc'`; then
    echo shar: \"'ifsout.doc'\" unpacked with wrong size!
fi
# end of 'ifsout.doc'
fi
if test -f 'source/gadmsg.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/gadmsg.c'\"
else
echo shar: Extracting \"'source/gadmsg.c'\" \(4976 characters\)
sed "s/^X//" >'source/gadmsg.c' <<'END_OF_FILE'
X/* a GADGETUP has been received, this routine 
X   takes the appropriate action
X*/
X
X#include "ifs.h"
X#include <exec/types.h>
X#include <intuition/intuition.h>
X
Xint checkvalidfun (funstr, currentfun, numoffun)
X  char *funstr;
X  int  currentfun, numoffun;
X{
X  int  numscaned,
X  fnum = 0;
X
X  numscaned = sscanf(funstr, "%5d", &fnum);
X  if ((numscaned>2) || (numscaned==0) || (fnum>FUNLIMIT) || (fnum<1))
X    return(currentfun);
X  else
X  return(fnum-1);		/* current function is 1 less than displayed */
X}         
X
Xfloat checkvalidcooef (funstr, cooef)
X   char *funstr;
X   float cooef;
X   
X{
X   int  numscaned;
X   float   scooef = 0.;
X
X   numscaned = sscanf(funstr,"%5f", &scooef);
X   if ((numscaned == 0) || (scooef > MAXCOFF) || (scooef < MINCOFF))
X      return(cooef);
X   else
X      return(scooef);
X}         
X
Xfloat checkvalidper (funstr, per)
X   char *funstr;
X   float per;
X   
X{
X   int  numscaned;
X   float   sper = 0.;
X
X   numscaned = sscanf(funstr, "%5f", &sper);
X   if ((numscaned == 0) || (sper > 1.) || (sper < 0.))
X      return(per);
X   else
X      return(sper);
X}         
X      
X    
Xvoid setpots(adjwin, gads, PInfos, funs, percent, 
X             xyscale, xoff, yoff, currentfun, numoffun, stxt, adjopen) 
X
X  struct Window *adjwin;
X  struct Gadget *gads;
X  struct PropInfo *PInfos;
X  float funs[][6], percent[], xyscale;
X  int    xoff, yoff, currentfun, numoffun;
X  UBYTE stxt[NUMSTRS][GSTRLEN];
X  short adjopen;
X{
X  int i;
X  if (adjopen) {
X    if(numoffun>0) 
X      PInfos[0].HorizPot = currentfun*FFFF / numoffun;  
X    for(i=0; i<6; i++) 
X      PInfos[i+1].HorizPot = (funs[currentfun][i]+1)*FFFF/3;
X    PInfos[7].HorizPot = (currentfun>0) 
X                     ? (percent[currentfun]-percent[currentfun-1])*FFFF
X                     : percent[currentfun]*FFFF;
X    PInfos[8].VertPot  = xyscale*FFFF/3;
X    PInfos[9].HorizPot= ((xoff/(float)WIDTH)+1)*FFFF/3;
X    PInfos[9].VertPot = FFFF *(.66 - (yoff/(3. * HEIGHT)));
X    sprintf(stxt[0],"%5d",currentfun+1);
X    for(i=0; i<6; i++)            /* change needed */
X      sprintf(stxt[i+1],"%5.2f", funs[currentfun][i]);
X    sprintf(stxt[7],"%5.2f", (currentfun>0) 
X                             ? percent[currentfun]-percent[currentfun-1] 
X                             : percent[currentfun]);
X    PInfos[0].HorizBody = FFFF / (numoffun+1);
X    if((adjwin->DetailPen = (currentfun+2)%MAXCOLORS) < 2)
X      adjwin->DetailPen = adjwin->DetailPen + 2;
X    RefreshGadgets(&gads[NUMGADS-1],adjwin,NULL);
X  }
X}
X
Xvoid adjpercent(numoffun, percent)
Xint numoffun;
Xfloat percent[];
X{
X  int i;
X
X  percent[0] = 1.0/(numoffun+1);
X  for (i=1;i<=numoffun;i++) {
X    percent[i] = percent[i-1] + 1.0/(numoffun+1);
X       
X  }
X}
X
Xvoid gadgetmessage(aptr,adjwin,funs,percent,xyscale,xoff,yoff,gads,PInfos,
X                   numoffun,currentfun,stxt,displaynumsw,adjopen)
X/* returns whether or not the screen needs to be cleared */
XAPTR aptr;
Xfloat funs[][6],percent[],*xyscale;
Xint   *xoff, *yoff,  *numoffun, *currentfun;
Xstruct Gadget *gads;
Xstruct Window *adjwin;
Xstruct PropInfo *PInfos;
XUBYTE stxt[NUMSTRS][GSTRLEN];
Xshort displaynumsw;
X{
X
X  short needrefresh = TRUE;
X  int i;
X
X  if (aptr == (APTR)&gads[0]) { 
X      /* this *numoffun+1 insures that Pot is placed right */
X      *currentfun = PInfos[0].HorizPot * (*numoffun+1)/ FFFF;
X      /* insure that currentfun is always <= numoffun */
X      if (*currentfun > *numoffun) (*currentfun)--; 
X      needrefresh = FALSE;
X  }
X  else if (aptr == (APTR)&gads[7]) {
X      percent[*currentfun] = (PInfos[7].HorizPot*1/ (float) FFFF); /*comp bug*/
X      if (*currentfun>0) percent[*currentfun] += percent[*currentfun-1];
X      }
X  else if (aptr == (APTR)&gads[8])              
X      *xyscale = (PInfos[8].VertPot*3/(float) FFFF);
X  else if (aptr == (APTR)&gads[9]) {
X      *xoff = ((PInfos[9].HorizPot*3/(float) FFFF) - 1)*WIDTH;
X      *yoff = HEIGHT * (2.0 - (3. * (PInfos[9].VertPot*1) / (float) FFFF)); 
X      /* another compiler bug*/
X  }
X  else if (aptr == (APTR)&gads[10]) {	/* Function Number String */
X      *currentfun = checkvalidfun(stxt[0],*currentfun,*numoffun);
X      if(*numoffun < *currentfun) {
X        *numoffun = *currentfun;
X        adjpercent(*numoffun, percent);
X        PInfos[0].HorizBody = FFFF / (*numoffun+1);
X        needrefresh = displaynumsw;
X      }
X      else needrefresh = FALSE;
X  }
X  else if (aptr == (APTR)&gads[17]) {
X      percent[*currentfun] = checkvalidper(stxt[7], percent[*currentfun]);
X      if (*currentfun>0) percent[*currentfun] += percent[*currentfun-1];
X      }
X
X  for (i=0; i<6; i++) {         /* change needed */
X    if (aptr == (APTR)&gads[i+1]) 
X      funs[*currentfun][i] = ((PInfos[i+1].HorizPot)*3/(float) FFFF) - 1.0;
X    if (aptr == (APTR)&gads[i+11])   /* one of the other strings */
X      funs[*currentfun][i] = checkvalidcooef(stxt[i+1], funs[*currentfun][i]);
X  }
X
X  setpots(adjwin, gads, PInfos, funs, percent, *xyscale, 
X          *xoff, *yoff, *currentfun, *numoffun, stxt, adjwin);
X  if (needrefresh) clearscreen();
X}
X
END_OF_FILE
if test 4976 -ne `wc -c <'source/gadmsg.c'`; then
    echo shar: \"'source/gadmsg.c'\" unpacked with wrong size!
fi
# end of 'source/gadmsg.c'
fi
if test -f 'source/getfile.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/getfile.c'\"
else
echo shar: Extracting \"'source/getfile.c'\" \(15557 characters\)
sed "s/^X//" >'source/getfile.c' <<'END_OF_FILE'
X/************************************************************************
Xreq.c
X	This file contains a general-purpose <requester> that
Xwill prompt the user for a filename input.
X	The program actually uses a window instead of a 'Requester'
Xfor greater flexibility. It will take control of your window's
XIDCMP Port when called.
X
X***	This material is copyright (c) 1986 by C. Heath of Microsmiths, Inc.
XPermission is granted to use these files in any way with the following
Xexceptions:
X
X1) The files shall not be posted on any telecommunications service, public
Xor private, except for BIX until January 15, 1987.
X
X2) The files may only be distributed in archive format, with no modifications.
XIf you make any improvements on the file requester and would like to
Xgenerally distribute them, please contact "cheath" on BIX, or write to:
X	Microsmiths Inc, PO Box 561, Cambridge, MA 02140
X
X3) The requester may be used in any commercial product, but must be in
Xobject code format.  You are free to make modifications for use in your
Xproduct.  Permission is granted to Lattice, Inc, and to Manx, Inc, to
Xinclude the source files in archive format.
X
X	Thank you, and enjoy.
X		...cheath
X
X5/1/89 -- Modified by Glen Fullmer to clean up compiler warnings.
X
X************************************************************************/
X
X#include "standard.h"
X#include "safeclose.h"
X
X#define FAST register
X#define NL NULL
X
Xextern char *dmore(), *dinit();
X
Xstatic struct FileLock      *pdir = NL;
Xstatic struct FileInfoBlock *dir_info;
X
Xstatic struct Window   *eW;		/* Parent Window. Uck	*/
X
Xstatic struct TextAttr MyFont = {"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT };
X
X/* FGAD requires a few unique gadget-ids, origined at FGAD	*/
X/* In the unlikely event this conflicts with any of your gadgets, */
X/* change this equate to allow 16 contiguous unique ID's	*/
X
X#define FGAD	0x76c0L
X
X#define FCHARS	32L	/* Number of chars allowed in file name	*/
X
X#define DIR_SIZ	50L	/* Number of chars in a dir name...	*/
X#define MAX_STR	DIR_SIZ+2L
X
X#define DENTS	5L		/* Number of entries on screen   */
X/* It's not as simple as changing 'DENTS'...      */
X
X#define DSIZE	FCHARS+1L	/* Size of a directory entry   */
X
X#define	DBUFSIZ	3000L	/* Number of bytes to allocate for all ents */
X
X#define BCOL	1L	/* Background color	*/
X#define FCOL	2L	/* Foreground color	*/
X
X#define RHGHT	120L
X#define RWDTH	320L
X
X#define ZWDTH	270L
X
Xstatic char	ubuf[MAX_STR];		/* Undo buffer	*/
X
Xvoid free_pdir();			/* dummy forwards to avoid compiler */
Xvoid cxxx();				/* warnings     */
Xvoid rfnam();
Xvoid notify();
X
Xstatic struct dirent { struct dirent *next; BOOL isfile; char dE[DSIZE+2]; };
Xstatic struct dirent *FirstEntry;
Xstatic struct dirent *NextEntry;
X
Xstatic struct dirhead { struct dirent *next; };
Xstatic struct dirhead ListHead;
X
Xstatic long   curent,maxent;
Xstatic BOOL   more;
X
Xstatic struct Window	*wRq = NL;		/* Requester window   */
Xstatic struct RastPort	*wRp;
X
X/* Requester "Hailing" prompt */
Xstatic struct IntuiText oTxt = {2,2,JAM1,10,11,NL, NL ,NL};
X
Xstatic struct IntuiText saydir = {0,1,JAM2,0,1,&MyFont,(UBYTE *)"(dir) ",NL};
X
Xstatic struct IntuiText rname[DENTS] = { /* File name list */
X   {2,1,JAM2,48,1,NL,NL, NL},
X   {2,1,JAM2,48,1,NL,NL, NL},
X   {2,1,JAM2,48,1,NL,NL, NL},
X   {2,1,JAM2,48,1,NL,NL, NL},
X   {2,1,JAM2,48,1,NL,NL, NL} };
X
X/* Display for file name ... */
X
Xstatic SHORT oXY2[] = {-2,-2, RWDTH-78,-2, RWDTH-78,9, -2,9, -2,-2};
Xstatic struct Border thebd = {0,0, 2,3,JAM1, 5,oXY2, NL};
X
Xstatic struct IntuiText otxt = {2,2,JAM1,-40,0,&MyFont,(UBYTE *)"file",NL};
Xstatic struct StringInfo osx = { NL ,ubuf, NL,DSIZE,NL,NL,NL,NL,NL,NL,NL,NL,NL};
Xstatic struct Gadget ogx = { NL, 60,RHGHT-35,RWDTH-80 ,10,     /* File name gadget */
X   GADGHCOMP, RELVERIFY , STRGADGET,
X   (APTR)&thebd,NL,&otxt,NL,(APTR)&osx, FGAD+11,NL };
X
Xstatic struct Gadget oga = { &ogx, 10,70, ZWDTH,10,   /* Gadgets For   */
X   GADGHCOMP, RELVERIFY, BOOLGADGET,     /* Directory entries   */
X   NL,NL, &rname[4] ,NL,NL, FGAD+10,NL };
Xstatic struct Gadget og9 = {&oga, 10,60, ZWDTH,10,
X   GADGHCOMP, RELVERIFY, BOOLGADGET,
X   NL,NL, &rname[3] ,NL,NL, FGAD+9,NL };
Xstruct Gadget og8 = {&og9, 10,50, ZWDTH,10,
X   GADGHCOMP, RELVERIFY, BOOLGADGET,
X   NL,NL, &rname[2] ,NL,NL, FGAD+8,NL };
Xstatic struct Gadget og7 = {&og8, 10,40, ZWDTH,10,
X   GADGHCOMP, RELVERIFY, BOOLGADGET,
X   NL,NL, &rname[1] ,NL,NL, FGAD+7,NL };
Xstatic struct Gadget og6 = {&og7, 10,30, ZWDTH,10,
X   GADGHCOMP, RELVERIFY, BOOLGADGET,
X   NL,NL, &rname[0] ,NL,NL, FGAD+6,NL };
X
X
X/* Gadjets for requester  */
X
Xstatic SHORT oXY3[] = {0,0, 50,0, 50,9, 0,9, 0,0};
Xstatic SHORT oXY4[] = {2,-2, 48,-2, 52,2, 52,7, 48,11, 2,11, -2,7, -2,2, 2,-2};
Xstatic struct Border obd2 = {0,0, 2,3,JAM1, 9,oXY4, NL};
Xstatic struct Border obd1 = {0,0, 3,2,JAM1, 5,oXY3, &obd2};  /* OTAY / CANCEL box */
X
Xstatic struct IntuiText ot1 = {0,0,JAM1,1,1,&MyFont,(UBYTE *)"  OK  ",NL};
Xstatic struct IntuiText ot2 = {0,0,JAM1,1,1,&MyFont,(UBYTE *)"Cancel",NL};
X
Xstatic struct IntuiText dtxt = {2,2,JAM1,-60,0,NL,(UBYTE *)"drawer",NL};
Xstatic struct StringInfo os5 = { NL ,ubuf, NL,DIR_SIZ,NL,NL,NL,NL,NL,NL,NL,NL,NL};
Xstatic struct Gadget og5 = { &og6, RWDTH/2-80,19,190,10,     /* Directory */
X   GADGHCOMP, RELVERIFY, STRGADGET,
X   NL,NL,&dtxt,NL,(APTR)&os5, FGAD+5,NL };
X
Xstatic struct Image   cc_img;
Xstatic struct PropInfo   cc_prop = {AUTOKNOB | FREEVERT, 0,0, 0,0x1000,0,0,0,0,0,0 };
Xstatic struct Gadget og3 = { &og5,RWDTH-39,20,20,60,      /* Scroll Bar   */
X    GADGHCOMP,GADGIMMEDIATE | FOLLOWMOUSE, PROPGADGET,
X    (APTR)&cc_img,NL,NL,NL,(APTR)&cc_prop,FGAD+3,NL };
X
Xstatic struct Gadget og2 = { &og3, RWDTH-70,RHGHT-20, 50,10,  /* CANCEL */
X   GADGHCOMP,  RELVERIFY, BOOLGADGET,
X   (APTR)&obd1,NL, &ot2,NL,NL, FGAD+2,NL };
X
Xstatic struct Gadget og1 = { &og2, 20,RHGHT-20, 50,10,      /* OTAY   */
X   GADGHCOMP,		/* Flags	*/
X   RELVERIFY,		/* Activation	*/
X   BOOLGADGET,
X   (APTR)&obd1,NL,	/* GadgetRender, SelectRender	*/
X   &ot1,NL,NL,		/* IntuiText, MutualExclude,SpecialInfo   */
X   FGAD+1,NL };		/* Gadget Id, UserData	*/
X
X/* Open a requester "Window" */
X
Xstatic struct NewWindow NewFiles = {
X   160, 30, RWDTH,RHGHT, BCOL,FCOL, NL, /* Fill in AFTER opening ... */
X   SMART_REFRESH | ACTIVATE | RMBTRAP | WINDOWDRAG,
X   &og1,NL,NL, NL,
X   NL, RWDTH,RHGHT,RWDTH,RHGHT, WBENCHSCREEN };
X
XIMPORT struct Library	*IntuitionBase;
X
X/***************************************************
X*  get_fname(window,screen,hail,ddef,ddir);
X*
X*   Displays a window/requester that
X* gets a file name for device,directory,default file, extension
X*
X*   Calling args:
X* window:   Window making the request
X* screen:   Screen, if NULL assummed workbench
X* hail:   Text prompt at top of requester
X* ddef:   Input default file-name. Has NO DIRECTORY OR EXTENSION.
X* ddir:   Directory of file, may be null
X
X/* Set a file-requester with prompt 'hail'   */
X
Xchar *get_fname(cW,screen,hail,ddef,ddir)
X   struct Window *cW;		/* Calling Window   */
X   struct Screen *screen;	/* screen .... if null assumed workbench */
X   UBYTE	*hail;		/* Hailing prompt   */
X   char		*ddef;		/* Proable file-name   */
X   char		*ddir;		/* Directory in which to search   */
X   {
X   FAST struct IntuiMessage *imes;   /* Wait for message in HERE   */
X   FAST struct Gadget	*igad;   /* Get Gadjet Mumbo Jumbo   */
X   FAST long	i,class;
X   FAST TEXT	*pnam;
X
X   FAST char	*retval;
X   FAST BOOL	dir_flag = FALSE;
X   FAST BOOL	keepon;
X
X   if ( ! (eW = cW) )   return(NL);
X
X   osx.Buffer = ddef;	/* Set default file name   */
X   os5.Buffer = ddir;	/* Set default device name   */
X
X   for ( i=0; i<DENTS; i++)
X      {
X      rname[i].IText = "";
X      rname[i].NextText = NL;
X      };
X
X   NewFiles.Title = eW->Title;
X   if ((dir_info = (struct FileInfoBlock *) 
X                   AllocMem((long)sizeof(struct FileInfoBlock),0L)) == NULL)
X      return(NL);
X
X   if (screen)		/* User supplied a screen */
X      {
X      NewFiles.Type = CUSTOMSCREEN;
X      NewFiles.Screen = screen;
X      }
X
X   if ( ! (FirstEntry = (struct dirent *)AllocMem((long)DBUFSIZ,0L)) ||
X        ! (wRq = (struct Window *)OpenWindow( &NewFiles )) )
X      {
X      if ( FirstEntry )   FreeMem(FirstEntry,(long)DBUFSIZ);
X      /* notify("Can't Open Requester..."); */
X      FreeMem(dir_info,(long)sizeof(struct FileInfoBlock));
X      return(NL);
X      }
X
X   /* Set up directory, notify any errors...   */
X   if ( pnam = (char *)dinit(ddir) )   notify(pnam);
X
X
X   /* This optional line will activate a string gadget	*/
X   if ( IntuitionBase->lib_Version > 32 )
X	{
X	ActivateGadget(&ogx,wRq,0L);
X	}
X
X   wRp = wRq->RPort;
X
X   wRq->UserPort = eW->UserPort;
X   ModifyIDCMP(wRq,(long)(MOUSEBUTTONS | GADGETDOWN | GADGETUP | MOUSEMOVE));
X
X   SetAPen(wRp,1L);
X   RectFill(wRp,4L,10L,(long)(RWDTH-5),(long)(RHGHT-4));
X
X   oTxt.IText = hail;   /* Set calling arg   */
X   oTxt.LeftEdge = (RWDTH - IntuiTextLength(&oTxt)) >> 1L;
X   PrintIText(wRp,&oTxt,0L,0L);
X
X   RefreshGadgets(&og1,wRq,(long)NL);
X   for ( retval= NL, keepon=TRUE; keepon ; )
X      {
X      while ( ! (imes=(struct IntuiMessage *)GetMsg(wRq->UserPort)) )
X      {
X         if ( dir_flag )
X            {
X            i = (maxent-DENTS) * cc_prop.VertPot / MAXBODY;
X            if ( i > (maxent-DENTS) )
X            i = maxent-DENTS;
X            if ( i <0 )   i = 0;
X            curent = i;
X            cxxx();
X            dir_flag = FALSE;
X            }
X         if ( more )
X            {
X            if (pnam = (char *)dmore())   /* Continue to read the directory */
X               notify(pnam);      /* Yucko error   */
X            if ( maxent <= DENTS ) dir_flag = TRUE;
X            }
X         else    WaitPort(wRq->UserPort);
X         }
X      igad = (struct Gadget *)imes->IAddress;
X      class = imes->Class;
X      ReplyMsg(imes);
X
X      switch (class)
X         {
X         case MOUSEMOVE:      dir_flag = TRUE;   break;
X      
X         case GADGETUP:
X         case GADGETDOWN:
X            switch ( i = igad->GadgetID)
X            {
X            case FGAD+6:
X            case FGAD+7:
X            case FGAD+8:
X            case FGAD+9:
X            case FGAD+10:       /* Replace file or directory name   */
X               pnam = rname[i - (FGAD+6)].IText;
X               if ( rname[igad->GadgetID - (FGAD+6)].NextText == NL )
X                  {
X                  RemoveGadget(wRq,&ogx);
X                  for (i=0; i<DSIZE; i++)      ddef[i] = *pnam++;
X                  AddGadget(wRq,&ogx,-1L);
X                  RefreshGadgets(&ogx,wRq,(long)NL);
X                  break;
X                  }
X                  else
X                  {
X                  RemoveGadget(wRq,&og5);
X                  rfnam(ddir,pnam);
X                  AddGadget(wRq,&og5,-1L);
X                  RefreshGadgets(&og5,wRq,(long)NL);
X                  }
X            case FGAD+5:
X               if ( pnam = (char *)dinit(ddir) )
X                  notify(pnam);
X            case FGAD+3:
X               dir_flag = TRUE;
X               break;
X
X            case FGAD+11:      /* Name gadget, OTAY gadget   */
X            case FGAD+1:
X               retval = ddef;
X            case FGAD+2:      /* Cancel gadget   */
X               keepon = FALSE;
X            }
X         }
X      }
X
X      FreeMem(FirstEntry,(long)DBUFSIZ );
X      FreeMem(dir_info,(long)sizeof(struct FileInfoBlock));
X      free_pdir();
X
X      CloseWindowSafely(wRq);
X      return(retval);
X   }
X
Xstatic void free_pdir()
X   {
X   if ( pdir )
X      {
X      UnLock(pdir);
X      pdir = NL;
X      }
X   }
X
X/*****************************************************************
X* dinit()
X*   Initialize the fib for directory muck.  Null return
X* is good, else return is a pointer to an error string      */
X
Xstatic char *dinit(subdir)
X   char *subdir;
X   {
X   more = FALSE;
X   curent = maxent = 0;
X
X   NextEntry = FirstEntry;      /* Allocate from here   */
X   ListHead.next = NL;          /* Clear the boogie     */
X
X   free_pdir();   /* Unlock any old lock... */
X
X   if (! (pdir=(struct FileLock *)Lock(subdir,(ULONG)ACCESS_READ)) )
X      return("Wrong Diskette?");
X   if ( ! Examine(pdir, dir_info) )   return("Wierd Disk Error");
X   if ( dir_info->fib_DirEntryType < 0L )   return("Bizzare Alert!!");
X
X   more = TRUE;
X   return(dmore());
X   }
X
X
Xstatic char *dmore()
X   {
X   FAST struct dirent   *p_D = NextEntry;
X   FAST struct dirent   *ptr = (struct dirent *)&ListHead;
X   FAST struct dirent   *plink;
X
X   FAST   TEXT   *p_mung;
X
X   FAST long    i;
X
X   if ( ! more )   return(NL);
X
X   if ( ExNext( pdir, dir_info ) )
X      {
X
X
X      if ( (ULONG)p_D >=
X         ((ULONG)FirstEntry + (ULONG)DBUFSIZ - (ULONG)sizeof(struct dirent)) )
X         {
X         more = FALSE;
X         return("Directory Truncated!");
X         }
X
X
X      /* Here you can add a file/directory filter   */
X      /* filename text string is at &p_D->dE[0   */
X      p_D->isfile = ( dir_info->fib_DirEntryType < 0L );
X
X      p_mung = &p_D->dE[0];
X      for ( i=0; i<FCHARS; i++)
X         if ( ! (*p_mung++ = dir_info->fib_FileName[i]) )   break;
X
X      i = (long)p_mung;
X      NextEntry = (struct dirent *)( (i+5L) & ~3L );
X
X      for ( i=maxent++; i>=0; i--)
X         {
X         if ( ! (plink = ptr->next)  )   break;
X         if ( alpha_lower(p_D,plink) )   break;
X         ptr = plink;
X         }
X      p_D->next = plink;
X      ptr->next = p_D;
X
X      return(NL);
X      }
X   else return ( IoErr() == ERROR_NO_MORE_ENTRIES) ?
X       (char *)(more = (long)NL) : "Error Reading Directory!!!";
X   }
X
X
X/* dedicated alphabetizing function for dmore()   */
X
Xstatic alpha_lower(snew,sold)
X   struct dirent *snew,*sold;
X   {
X   FAST struct dirent *pnew = snew;
X   FAST TEXT *ps1,*ps2, c,d;
X
X   if ( pnew->isfile == sold->isfile)
X      {
X      ps1 = &pnew->dE[0];
X      ps2 = &sold->dE[0];
X      while ( (c=*ps1++) )
X         {
X         if ( c > (d=*ps2++) )   return(FALSE);
X         else if ( c < d )      break;
X         }
X      return(TRUE);
X      }
X   return(pnew->isfile);
X   }   
X
X
X
X/* Display directory stuff   */
X
Xstatic void cxxx()
X   {
X   FAST long   i,new;
X   FAST long   x,y;
X   FAST struct dirent *ohboy = (struct dirent *)&ListHead;
X
X   new = curent;
X   for ( i=0; i<new; i++)   ohboy = ohboy->next;
X
X   y = 20L;
X   for (i=0; i<DENTS; i++)
X      {
X      y += (x=10);
X      rname[i].NextText = NL;
X      rname[i].IText = "";
X      rname[i].LeftEdge = 0;
X      if ( (new+i) < maxent )
X         {
X         ohboy = ohboy->next;
X         rname[i].IText = &ohboy->dE[0];
X         if ( ohboy->isfile )   PrintIText(wRp,&rname[i],10L,y);
X         else
X            {
X            rname[i].LeftEdge = 48;
X            PrintIText(wRp,&saydir,10L,y);
X            PrintIText(wRp,&rname[i],10L,y);
X            rname[i].NextText = &saydir;
X            }
X         x = wRp->cp_x;
X         }
X      if ( x < ZWDTH+10 )   RectFill(wRp,x,y,(long)(ZWDTH+10),(long)(y+8L));
X      }
X   }
X
X
X/**************************************************
X* rfnam()
X*   Combines dir, plus name into dir   */
X
Xstatic void rfnam(dir,fil_nam)
X   char *dir,*fil_nam;
X   {
X   FAST char   *pdst = dir;
X   FAST char   *psrc = fil_nam;
X   FAST char   c = ':';
X
X   while ( *pdst )
X      c = *pdst++;
X   if ( c != ':')   *pdst++ = '/';
X
X   while ( *pdst++ = *psrc++ )
X      ;
X   }
X
Xstatic struct IntuiText b_txt = {0,1,JAM2, 5,20,NL,NL,    NL};
Xstatic struct IntuiText p_txt = {0,1,JAM2, 5,3,NL,"OK", NL};
X
X/****************************************************************/
X/* notify(txt)                     */
X/*   Prompts for Yes/No response            */
X
Xstatic void notify(txt)
X   char *txt;
X   {
X   b_txt.IText = txt;
X   AutoRequest(wRq,&b_txt,0L,&p_txt,0L,0L,
X      (long)(IntuiTextLength(&b_txt)+50L),70L);
X   }
END_OF_FILE
if test 15557 -ne `wc -c <'source/getfile.c'`; then
    echo shar: \"'source/getfile.c'\" unpacked with wrong size!
fi
# end of 'source/getfile.c'
fi
if test -f 'source/ifsout.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/ifsout.h'\"
else
echo shar: Extracting \"'source/ifsout.h'\" \(16819 characters\)
sed "s/^X//" >'source/ifsout.h' <<'END_OF_FILE'
X/*
X*
X*
X*     IFSout.h - Header file for the Iterated Function System
X*                uses IFS to create a IFS-Construction Image
X*     Released to the Public Domain - 1990 The Software Glen Company
X*
X*
X*/
X
X#include <stdio.h>
X#include <exec/libraries.h>
X#include <graphics/display.h>
X#include <graphics/gfxbase.h>
X#include <graphics/text.h>
X#include <math.h>
X#include <limits.h>
X
XUBYTE stxt[NUMSTRS][GSTRLEN];          /* For the String Gadget Text    */
X
Xstruct   GfxBase       *GfxBase;       /* Export the library pointers   */
Xstruct   IntuitionBase *IntuitionBase;
Xstruct   RastPort      *rp;            /* Graphics structures           */
Xstruct   ViewPort      *vp;
X
Xstruct TextAttr StdFont = {
X       "topaz.font",                   /* Standard system font */
X       8,    0,    0
X};
X
Xstruct   Window        *w, *adjwin;    /* Intuition structures        */ 
Xstruct   Screen        *screen;
Xstruct   IntuiMessage  *message;
X
Xstruct Gadget gads[NUMGADS];       
X
Xstruct Image PImages[NUMPROPS];        /* dummy AUTOKNOB Images are required */
Xstruct PropInfo PInfos[NUMPROPS];      /* These get copies of TPropInfo  */
X
Xstruct StringInfo SInfo[NUMSTRS];
X
Xstruct IntuiText StrngText[NUMSTRS]  = {
X      {2, 0, JAM2, -30, 0, NULL, "WN= ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "A = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "B = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "C = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "D = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "E = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "F = ", NULL},
X      {2, 0, JAM2, -30, 0, NULL, "% = ", NULL}
X};
X
Xstruct IntuiText MenuItemText[3][7] = {
X   {
X      {0, 1, JAM2, 0, 0, NULL, "About...", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Save IFS", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Get  IFS", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "To WB   ", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Quit    ", NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X   },
X
X   {   
X      {0, 1, JAM2, 0, 0, NULL, "Zoom to Fit  ", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Zoom Out X 2 ", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Adjust Func  ", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Add Another  ", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Erase Current", NULL},
X      {0, 1, JAM2, 0, 0, NULL, "Erase All    ", NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X   },
X   
X   {
X      {0, 1, JAM2, CHECKWIDTH, 0, NULL, "Boxes  ", NULL},
X      {0, 1, JAM2, CHECKWIDTH, 0, NULL, "Numbers", NULL},
X      {0, 1, JAM2, CHECKWIDTH, 0, NULL, "Pause  ", NULL},
X      {0, 1, JAM2, CHECKWIDTH, 0, NULL, "BlkGrnd", NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X   }
X};
X
Xstruct MenuItem MenuItem[3][7] = {
X   {
X      {&MenuItem[0][1], 0,  0, 64, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[0][0], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[0][2], 0, 20, 64, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[0][1], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[0][3], 0, 40, 64, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP,
X          0, (APTR)&MenuItemText[0][2], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[0][4], 0, 60, 64, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP,
X          0, (APTR)&MenuItemText[0][3], NULL, NULL, NULL, 0xFFFF},
X      {NULL,            0, 80, 64, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP,
X          0, (APTR)&MenuItemText[0][4], NULL, NULL, NULL, 0xFFFF},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X      },
X   {
X      {&MenuItem[1][1], 0,  0, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][0], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[1][2], 0, 20, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][1], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[1][3], 0, 40, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][2], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[1][4], 0, 60, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][3], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[1][5], 0, 80, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][4], NULL, NULL, NULL, 0xFFFF},
X      {NULL,            0,100, 104, 10, ITEMTEXT|ITEMENABLED|HIGHCOMP, 
X          0, (APTR)&MenuItemText[1][5], NULL, NULL, NULL, 0xFFFF},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X
X      },
X      
X      {
X      {&MenuItem[2][1], 0,  0, 56+CHECKWIDTH, 10, 
X        ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|MENUTOGGLE,
X          0, (APTR)&MenuItemText[2][0], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[2][2], 0, 20, 56+CHECKWIDTH, 10, 
X        ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|CHECKED|MENUTOGGLE, 
X          0, (APTR)&MenuItemText[2][1], NULL, NULL, NULL, 0xFFFF},
X      {&MenuItem[2][3], 0, 40, 56+CHECKWIDTH, 10, 
X        ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|MENUTOGGLE, 
X          0, (APTR)&MenuItemText[2][2], NULL, NULL, NULL, 0xFFFF},
X      {NULL,            0, 60, 56+CHECKWIDTH, 10, 
X        ITEMTEXT|ITEMENABLED|HIGHCOMP|CHECKIT|CHECKED|MENUTOGGLE,
X          0, (APTR)&MenuItemText[2][3], NULL, NULL, NULL, 0xFFFF},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
X      {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
X      }
X   };
X
X
Xstruct Menu Menu[3] = {
X   {&Menu[1],   0,  0, 60,  0, MENUENABLED, "Project", &MenuItem[0][0]},
X   {&Menu[2],  81,  0, 76,  0, MENUENABLED, "Functions", &MenuItem[1][0]},
X   {NULL,     171,  0, 60,  0, MENUENABLED, "Control", &MenuItem[2][0]}
X   };
X
X
Xstruct PropInfo TPropInfo = {
X   AUTOKNOB | FREEHORIZ,  /* Flags */
X   0, 0,            /* Pots:  Horiz, Vert: both start at 0 */
X   0x00D4, 0x00D4,  /* Bodies: Horiz is 1/300, Vert is 1/300 */
X   0, 0, 0, 0, 0, 0 /* System usage stuff */
X};
X
X
X/* this is the template for the Gadget of a horizonal */
X/* Proportional Gadget */
X
Xstruct Gadget TPropGadget = {
X   NULL,                      /* pointer to NextGadget      */
X   110, GADSIZE, (WIDTH/4), GADSIZE,  /* Select Box L T W H         */
X   GADGHCOMP,                 /* Flags                      */
X   GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,   /* Activation flags           */
X   PROPGADGET,                /* Type                       */
X   NULL,                      /* pointer to Image filled in later */
X   NULL,                      /* no pointer to SelectRender filled later    */
X   NULL,                      /* no pointer to GadgetText   */
X   0,                         /* no MutualExclude           */
X   NULL,                      /* SpecialInfo proportional data filled later */
X   0,                         /* no ID                      */
X   NULL                       /* no pointer to special data */
X};
X
Xstruct Gadget ZoomGadget = {
X   NULL,                      /* pointer to NextGadget      */
X   340, (2*GADSIZE), (2*GADSIZE), 80,  /* Select Box L T W H        	*/
X   GADGHCOMP,                 /* Flags                      */
X   GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,   /* Activation flags 	*/
X   PROPGADGET,                /* Type                       */
X   NULL,                      /* pointer to Image filled in later */
X   NULL,                      /* no pointer to SelectRender */
X   NULL,                      /* no pointer to GadgetText   */
X   0,                         /* no MutualExclude           */
X   NULL,                      /* SpecialInfo proportional filled in later*/
X   0,                         /* no ID                      */
X   NULL                       /* no pointer to special data */
X};
X
Xstruct Gadget CenterGadget = {
X   NULL,                      /* pointer to NextGadget      */
X   440, GADSIZE*2, (WIDTH/4), 80,  /* Select Box L T W H         */
X   GADGHCOMP,                 /* Flags                      */
X   GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,   /* Activation flags           */
X   PROPGADGET,                /* Type                       */
X   NULL,                      /* pointer to Image filled in later */
X   NULL,                      /* no pointer to SelectRender */
X   NULL,                      /* no pointer to GadgetText   */
X   0,                         /* no MutualExclude           */
X   NULL,                      /* SpecialInfo proportional filled in later*/
X   0,                         /* no ID                      */
X   NULL                       /* no pointer to special data */
X};
X
Xstruct Gadget TStrngGadget = {
X   NULL,                      /* pointer to NextGadget      */
X   40, GADSIZE, 50, GADSIZE,  /* Select Box L T W H         */
X   GADGHCOMP,                 /* Flags                      */
X   RELVERIFY | ENDGADGET,     /* Activation flags           */
X   STRGADGET,                 /* Type                       */
X   NULL,                      /* pointer to Image filled in later */
X   NULL,                      /* no pointer to SelectRender filled later    */
X   NULL,                      /* no pointer to GadgetText   */
X   0,                         /* no MutualExclude           */
X   NULL,                      /* SpecialInfo proportional data filled later */
X   0,                         /* no ID                      */
X   NULL                       /* no pointer to special data filled in later*/
X};
X
X/* This is the text for the About requester */
X#define TXT01   ""
X#define TXT02   "         AMIGA IFSOUT V1.4"
X#define TXT03   "Public Domain by Software Glen Co."
X#define TXT04   "An Iterated Function System Viewer"
X#define TXT05   ""
X#define TXT06   "I would be interested in any new &"
X#define TXT07   "interesting functions you find.   "
X#define TXT08   ""
X#define TXT09   " Glen Fullmer"
X#define TXT10   " email fullmer@alfalfa.sps.mot.com"
X#define TXT11   ""
X#define TXT12   ""
X#define TXT13	"Algorithm from FRACTALS EVERYWHERE"
X#define TXT14 	"               by Michael Barnsley"
X
Xstruct IntuiText ReqText14 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   133,          /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT14,
X   NULL          /* next */
X};
Xstruct IntuiText ReqText13 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   123,          /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT13,
X   &ReqText14    /* next */
X};
Xstruct IntuiText ReqText12 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   113,          /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT12,
X   &ReqText13    /* next */
X};
Xstruct IntuiText ReqText11 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   103,          /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT11,
X   &ReqText12    /* next */
X};
Xstruct IntuiText ReqText10 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   93,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT10,
X   &ReqText11    /* next */
X};
Xstruct IntuiText ReqText9 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   83,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT09,
X   &ReqText10    /* next */
X};
Xstruct IntuiText ReqText8 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   73,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT08,
X   &ReqText9     /* next */
X};
Xstruct IntuiText ReqText7 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   63,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT07,
X   &ReqText8     /* next */
X};
Xstruct IntuiText ReqText6 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   53,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT06,
X   &ReqText7     /* next */
X};
Xstruct IntuiText ReqText5 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   43,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT05,
X   &ReqText6     /* next */
X};
Xstruct IntuiText ReqText4 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   33,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT04,
X   &ReqText5     /* next */
X};
Xstruct IntuiText ReqText3 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   23,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT03,
X   &ReqText4     /* next */
X};
Xstruct IntuiText ReqText2 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   13,           /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT02,
X   &ReqText3     /* next */
X};
Xstruct IntuiText ReqText1 = {
X   0,            /* Front Pen */
X   1,            /* Back pen */
X   JAM2,         /* Draw Mode */
X   5,            /* Left Edge */
X   3,            /* Top */
X   &StdFont,     /* pointer to TextFont */
X   TXT01,
X   &ReqText2     /* next */
X};
X
X
Xstruct IntuiText OKIText = {
X   0, 1      , /* FrontPen, BackPen */
X   JAM2,       /* DrawMode */
X   6, 3,       /* LeftEdge, TopEdge (relative to gadget) */
X   &StdFont,   /* pointer to TextFont */
X   "OK",       /* pointer to Text */
X   NULL        /* no pointer to NextText */
X};
X
X
Xstruct   NewScreen ns = {
X   0, 0,                               /* start position                */
X   640, 400, 4,                        /* width, height, depth          */
X   0, 1,                               /* detail pen, block pen         */
X   HIRES|INTERLACE,                    /* Normal ViewMode               */
X   CUSTOMSCREEN,                       /* screen type                   */
X   &StdFont,                           /* font to use                   */
X   SCREENTITLE,                        /* default title for screen      */
X   NULL                                /* pointer to additional gadgets */
X};
X
Xstruct NewWindow nw = {
X   0, 0,                               /* start position                */
X   WIDTH, HEIGHT,                      /* width, height                 */
X   -1, -1,                             /* detail pen, block pen         */
X   CLOSEWINDOW|MOUSEBUTTONS|MENUPICK|INTUITICKS,  /* IDCMP flags        */
X                                       /* Window flags*/
X   WINDOWCLOSE|ACTIVATE|BORDERLESS|SMART_REFRESH|NOCAREREFRESH,
X   NULL,                               /* Pointer to FirstGadget        */
X   NULL,                               /* pointer to user checkmark     */
X   NULL,                               /* window title                  */
X   NULL,                               /* pointer to screen (set below) */
X   NULL,                               /* pointer to superbitmap        */
X   0, 0, 640, 373,                     /* ignored since not sizeable    */
X   CUSTOMSCREEN                        /* type of screen desired        */
X};
X
Xstruct NewWindow nadjwin = {
X   0, 20,                              /* start position                */
X   WIDTH,(((NUMPROPS-2) * GADSIZE)+30),/* width, height                 */
X   2,1,                                /* detail pen, block pen         */
X   CLOSEWINDOW | GADGETUP,             /* IDCMP flags        */
X   WINDOWCLOSE|WINDOWDRAG|SMART_REFRESH|NOCAREREFRESH, /* window flags */
X   &gads[NUMGADS-1],                   /* Pointer to FirstGadget        */
X   NULL,                               /* pointer to user checkmark     */
X   "Coefficients      Adjust              Zoom              Reposition        ",/* window title                  */
X   NULL,                               /* pointer to screen (set below) */
X   NULL,                               /* pointer to superbitmap        */
X   0, 0, 0, 0,                         /* ignored since not sizeable    */
X   CUSTOMSCREEN                        /* type of screen desired        */
X
X};
END_OF_FILE
if test 16819 -ne `wc -c <'source/ifsout.h'`; then
    echo shar: \"'source/ifsout.h'\" unpacked with wrong size!
fi
# end of 'source/ifsout.h'
fi
if test -f 'source/makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/makefile'\"
else
echo shar: Extracting \"'source/makefile'\" \(1804 characters\)
sed "s/^X//" >'source/makefile' <<'END_OF_FILE'
XDIR = IFS:work/
XBIN = IFS:bin/
XDOC = IFS:
X
XLFLAGS    = 
XADDSYMX   = 
XCFLAGS    = -ff -rs -O
X
XSRC       = ifs???.h ifs???.c vectors.? gadmsg.? getfile.? safe?????.? standard.? 
X
XOBJS      = ifsout.o vectors.o gadmsg.o safeclose.o getfile.o
XBINS      = ifsout
X
X
X#	For Debug
X#CFLAGS = -d2 
X#ADDSYMX = ADDSYM
X
Xall:	ifsout
X
Xifsout.o: 
X	lc $(CFLAGS) ifsout.c
X
Xgadmsg.o: 
X	lc $(CFLAGS) gadmsg.c
X
Xvectors.o: vectors.c
X	lc $(CFLAGS) vectors.c
X
Xgetfile.o: 
X	lc $(CFLAGS) getfile.c
X
Xsafeclose.o: 
X	lc $(CFLAGS) safeclose.c
X
Xifsout:	$(OBJS)
X	blink $(LFLAGS) lib:c.o $(OBJS) to ifsout \
Xlib lib:lcmffp.lib lib:lcm.lib lib:lc.lib lib:amiga.lib $(ADDSYMX)
X
Xrealclean: 
X	delete $(SRC) 
X	delete $(BINS)
X	delete buglist makefile ifsout.doc ifsout.info
X	delete $(OBJS)
X
Xclean:
X	delete $(OBJS)
X
Xsave:
X	copy ifs???.c $(DIR)
X	copy gad???.c $(DIR)
X	copy vec????.c $(DIR)
X	copy make????  $(DIR)
X	copy ifs.?     $(DIR)      
X	copy ifs???.h $(DIR)
X	copy get????.h $(DIR)
X	copy safe?????.h $(DIR)
X	copy stand???.h    $(DIR)
X	copy get????.c $(DIR)
X        copy bug????   $(DIR)
X	copy safe?????.c $(DIR)
X        copy ifs???  $(BIN)
X	copy ifs???.info $(BIN)
X	copy ifsout.d?? $(DOC)
X	copy ifsout.d??.info $(DOC)
X	copy ifsout.??? $(DIR)
X
X
Xget:
X	copy $(DIR)ifsout.c  rad:ifsout.c
X	copy $(DIR)gadmsg.c rad:gadmsg.c
X	copy $(DIR)vectors.c rad:vectors.c
X	copy $(DIR)makefile rad:makefile
X	copy $(DIR)ifs.h    rad:ifs.h
X	copy $(DIR)ifsout.h rad:ifsout.h
X	copy $(DIR)getfile.h rad:getfile.h
X	copy $(DIR)safeclose.h rad:safeclose.h
X	copy $(DIR)standard.h rad:standard.h 
X	copy $(DIR)getfile.c rad:getfile.c 
X	copy $(DIR)safeclose.c rad:safeclose.c 
X        copy $(DIR)buglist rad:buglist
X	copy $(BIN)ifsout.info rad:ifsout.info
X	copy $(DOC)ifsout.doc rad:ifsout.doc
X	copy $(DOC)ifsout.doc.info rad:ifsout.doc.info
X	copy $(BIN)ifsout rad:ifsout
END_OF_FILE
if test 1804 -ne `wc -c <'source/makefile'`; then
    echo shar: \"'source/makefile'\" unpacked with wrong size!
fi
# end of 'source/makefile'
fi
if test -f 'source/vectors.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/vectors.c'\"
else
echo shar: Extracting \"'source/vectors.c'\" \(5675 characters\)
sed "s/^X//" >'source/vectors.c' <<'END_OF_FILE'
X#include "ifs.h"
X#include "standard.h"
X
X#define JAM1       0
X#define JAM2       1
X#define COMPLEMENT 2
X#define INVERDVID  4
X
Xvoid drawonebox();
Xvoid checkswitches();
Xvoid autoadj();
Xint  closeby();
Xvoid adjust();
Xvoid checkswitches();
X
Xvoid drawvectors(rp, funs, numoffun, currentfun)
X   struct   RastPort      *rp;
X   float funs[][6];
X   int numoffun, currentfun;
X{
X  int  i, color;
X  
X  for (i=0; i<=numoffun; i++) {
X     if ((color = (i+2)%MAXCOLORS) < 2)
X       color = color+2;		/* paint with correct color */
X     SetAPen(rp, color);
X     drawonebox(rp,funs[i]);
X  }
X  SetAPen(rp,1);
X  drawonebox(rp,funs[currentfun]);
X}
X
Xvoid drawonebox(rp, afun)
X   struct   RastPort      *rp;
X   float afun[6];
X{
X  short  x[10], j;
X 
X  Move(rp, (int) (WIDTH/2  + DISPSCALE * afun[4] * WIDTH),
X           (int) (HEIGHT/2 - DISPSCALE * afun[5] * HEIGHT));
X  j=0;
X  x[j++] = WIDTH/2  + DISPSCALE * (afun[0] + afun[4]) * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * (afun[2] + afun[5]) * HEIGHT;
X  x[j++] = WIDTH/2  + DISPSCALE * (afun[0] + afun[1] + afun[4]) * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * (afun[2] + afun[3] + afun[5]) * HEIGHT;
X  x[j++] = WIDTH/2  + DISPSCALE * (afun[1] + afun[4]) * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * (afun[3] + afun[5]) * HEIGHT;
X  x[j++] = WIDTH/2  + DISPSCALE * afun[4] * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * afun[5] * HEIGHT;
X  PolyDraw(rp, 4, &x[0]);
X  Move(rp, (int) (WIDTH/2  + DISPSCALE * (afun[0]/4 + afun[4]) * WIDTH),
X           (int) (HEIGHT/2 - DISPSCALE * (afun[2]/4 + afun[5]) * HEIGHT));
X  j=0;			/* draw little box in right hand corner */
X  x[j++] = WIDTH/2  + DISPSCALE * (afun[0]/4 + afun[1]/4 + afun[4]) * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * (afun[2]/4 + afun[3]/4 + afun[5]) * HEIGHT;
X  x[j++] = WIDTH/2  + DISPSCALE * (afun[1]/4 + afun[4]) * WIDTH;
X  x[j++] = HEIGHT/2 - DISPSCALE * (afun[3]/4 + afun[5]) * HEIGHT;
X  PolyDraw(rp, 2, &x[0]);  
X                             /* and slash in adjacent corner */
X  Move(rp, (int) (WIDTH/2  + DISPSCALE * (afun[0]*.75 + afun[4]) * WIDTH),
X           (int) (HEIGHT/2 - DISPSCALE * (afun[2]*.75 + afun[5]) * HEIGHT));
X  Draw(rp, (int) (WIDTH/2  + DISPSCALE * (afun[0] 
X                           + afun[1]/4 + afun[4]) * WIDTH),
X           (int) (HEIGHT/2 - DISPSCALE * (afun[2] 
X                           + afun[3]/4 + afun[5]) * HEIGHT));
X}
X
X
Xint closeby (funs, currentfun, numoffun, mx, my) 
X
Xfloat funs[][6];
Xint   *currentfun, numoffun;
XUSHORT mx, my;
X
X{
X  int xc[4], yc[4], i, j, thecorner = 0, hit=FALSE, thefun;
X    
X  for (j=0;j<=numoffun;j++) {
X     xc[0] = WIDTH/2  + DISPSCALE * funs[j][4] * WIDTH;
X     yc[0] = HEIGHT/2 - DISPSCALE * funs[j][5] * HEIGHT;
X
X     xc[1] = WIDTH/2  + DISPSCALE * (funs[j][0] + funs[j][4]) * WIDTH;
X     yc[1] = HEIGHT/2 - DISPSCALE * (funs[j][2] + funs[j][5]) * HEIGHT;
X  
X     xc[2] = WIDTH/2  + DISPSCALE 
X             * (funs[j][0] + funs[j][1] + funs[j][4]) * WIDTH;
X     yc[2] = HEIGHT/2 - DISPSCALE 
X             * (funs[j][2] + funs[j][3] + funs[j][5]) * HEIGHT;
X     xc[3] = WIDTH/2  + DISPSCALE * (funs[j][1] + funs[j][4]) * WIDTH;
X     yc[3] = HEIGHT/2 - DISPSCALE * (funs[j][3] + funs[j][5]) * HEIGHT;
X
X     for (i=0;i<4;i++) {
X       xc[i] = mx - xc[i];
X       yc[i] = my - yc[i];
X       if (xc[i] < 0) xc[i] = - xc[i];
X       if (yc[i] < 0) yc[i] = - yc[i];
X       if (xc[i] < EPSILON && yc[i] < EPSILON) 
X          if (hit == FALSE) {
X             thecorner = i+1;		        /* is closeby */
X             thefun = j;
X             hit = TRUE;
X          }
X          else				        /* two at same point */
X             if (j == *currentfun) {            /* select currentfun */
X                thecorner = i+1;
X                thefun = j;
X	     }
X          
X     }
X  }
X  if (hit == TRUE) *currentfun = thefun;
X  return (thecorner);
X  }       /* end closeby */
X
Xvoid adjust(corner, rp, funs, currentfun, mx, my) /* returns 1 if moved */
X  int corner;
X  struct   RastPort      *rp;
X  float funs[][6];
X  int currentfun;
X  USHORT mx, my;
X
X{
X  float ta, tb, tc, td, te, tf;
X
X  ta = funs[currentfun][0];
X  tb = funs[currentfun][1];
X  tc = funs[currentfun][2];
X  td = funs[currentfun][3];
X  te = funs[currentfun][4];
X  tf = funs[currentfun][5];
X
X  switch (corner) {
X    case 1:
X      te = (mx - WIDTH/2)/(DISPSCALE * WIDTH);
X      tf = (HEIGHT/2 - my)/(DISPSCALE * HEIGHT);
X      break;
X    case 2:
X      ta = (mx - WIDTH/2)/(DISPSCALE * WIDTH)   - te; 
X      tc = (HEIGHT/2 - my)/(DISPSCALE * HEIGHT) - tf;
X      break;
X    case 3:
X      ta = (mx - WIDTH/2)/(DISPSCALE * WIDTH)   - te - tb; 
X      td = (HEIGHT/2 - my)/(DISPSCALE * HEIGHT) - tf - tc;
X      break;
X    case 4: 
X      tb = (mx - WIDTH/2)/(DISPSCALE * WIDTH)   - te;
X      td = (HEIGHT/2 - my)/(DISPSCALE * HEIGHT) - tf;
X      break;
X  }
X  if (ta >= MINCOFF && ta <= MAXCOFF &&
X      tb >= MINCOFF && tb <= MAXCOFF &&
X      tc >= MINCOFF && tc <= MAXCOFF &&
X      td >= MINCOFF && td <= MAXCOFF &&
X      te >= MINCOFF && te <= MAXCOFF &&
X      tf >= MINCOFF && tf <= MAXCOFF) {
X   
X      funs[currentfun][0] = ta;
X      funs[currentfun][1] = tb;
X      funs[currentfun][2] = tc;
X      funs[currentfun][3] = td;
X      funs[currentfun][4] = te;
X      funs[currentfun][5] = tf;
X      SetDrMd(rp,COMPLEMENT);
X      drawonebox(rp, funs[currentfun]);
X      drawonebox(rp, funs[currentfun]);
X      SetDrMd(rp,JAM1);
X      }
X}
X
Xvoid checkswitches(rp,funs,percent,currentfun,numoffun,vectorsw,displaynumsw)
X  struct   RastPort      *rp;
X  float funs[][6], percent[];
X  int currentfun, numoffun;
X  short vectorsw, displaynumsw;
X{
X  if (vectorsw) 
X     drawvectors(rp, funs, numoffun, currentfun);
X  if (displaynumsw) 
X     displaynums(rp, funs, percent, currentfun, numoffun);
X}
END_OF_FILE
if test 5675 -ne `wc -c <'source/vectors.c'`; then
    echo shar: \"'source/vectors.c'\" unpacked with wrong size!
fi
# end of 'source/vectors.c'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.