[comp.sources.x] v03i048: The Chaos Game, Patch1

mikew@wyse.wyse.com (Mike Wexler) (03/11/89)

Submitted-by: Nathan K. Meyers <nathanm%hpcvxnkm@hp-sde.sde.hp.com>
Posting-number: Volume 3, Issue 48
Archive-name: chaos/patch1



These patches to chaos add a feature and clean up the program slightly.
The README file now reflects the the behavior of the boilerplate
makefile added by the moderator to my previous posting.

Nathan Meyers
nathanm@hp-pcd.hp.com

============================================================================

*** orig-README	Tue Mar  7 09:24:49 1989
--- README	Tue Mar  7 09:24:29 1989
***************
*** 8,14
  
  To make on systems of SYSV descent (such as hp-ux):
  
! 	make SYSV
  
  ---------------------
  Nathan Meyers

--- 8,14 -----
  
  To make on systems of SYSV descent (such as hp-ux):
  
! 	make "CDEBUGFLAGS=-O -DSYSV"
  
  ---------------------
  Nathan Meyers





*** orig-chaos.1	Tue Mar  7 09:24:50 1989
--- chaos.1	Tue Mar  7 09:24:29 1989
***************
*** 8,13
  \fBchaos\fR
  [\|\fB-bd\fR border\|] [\|\fB-bg\fR background\|] [\|\fB-bw\fR borderwidth\|]
  [\|\fB-delay\fR msec\|] [\|\fB-display\fR displayname\|]
  [\|\fB-geometry\fR geometry\|]
  [\|\fB-mpoints\fR\|]
  [\|\fB-out\fR bitmapfile\|]

--- 8,14 -----
  \fBchaos\fR
  [\|\fB-bd\fR border\|] [\|\fB-bg\fR background\|] [\|\fB-bw\fR borderwidth\|]
  [\|\fB-delay\fR msec\|] [\|\fB-display\fR displayname\|]
+ [\|\fB-dist\fR distance\|]
  [\|\fB-geometry\fR geometry\|]
  [\|\fB-mpoints\fR\|]
  [\|\fB-out\fR bitmapfile\|]
***************
*** 74,79
  Specify display on which to run; defaults to contents of DISPLAY
  environment variable.
  .TP
  .B -geometry
  Specify window geometry; defaults to =300x300+0+0.
  .TP

--- 75,86 -----
  Specify display on which to run; defaults to contents of DISPLAY
  environment variable.
  .TP
+ .B -dist
+ Allows you to specify the distance moved for each point.  Default value
+ is 0.5.  When this option is used, point P\v'+.2v'\s-2n\v'-.2v'\s0 will
+ be located the specified fraction of the distance between
+ P\v'+.2v'\s-2n-1\v'-.2v'\s0 and the selected vertex.
+ .TP
  .B -geometry
  Specify window geometry; defaults to =300x300+0+0.
  .TP
***************
*** 138,141
  chaos -points 0,0,.3,1,.7,1,1,0
  .SH AUTHORSHIP
  \fIChaos\fR was authored by Nathan Meyers of Hewlett-Packard
! (nathanm@hp-pcd).

--- 145,150 -----
  chaos -points 0,0,.3,1,.7,1,1,0
  .SH AUTHORSHIP
  \fIChaos\fR was authored by Nathan Meyers of Hewlett-Packard
! (nathanm@hp-pcd).  Thanks to Paul T. Keener of the University
! of Pennsylvania (keener@upenn5.hpe.upenn.edu) for the -dist
! option.





*** orig-chaos.c	Tue Mar  7 09:24:53 1989
--- chaos.c	Tue Mar  7 09:24:29 1989
***************
*** 20,26
  
  char *progname;
  
! static char *what = "@(#)chaos.c $Revision: 1.13 $";
  
  struct dattract {
    double x,y;

--- 20,26 -----
  
  char *progname;
  
! static char *what = "@(#)chaos.c $Revision: 1.17 $";
  
  struct dattract {
    double x,y;
***************
*** 29,35
  		 { 0.5, 0.846410161513 } };
  
  struct dattract *fpoints = dpoints;
- int npoints = 3;
  char *strchr();
  
  main(argc,argv)
  int argc;

--- 29,34 -----
  		 { 0.5, 0.846410161513 } };
  
  struct dattract *fpoints = dpoints;
  
  main(argc,argv)
  int argc;
***************
*** 49,55
    char *foreground = NULL, *background = NULL, *border = NULL;
    char *geomstring = NULL;
    XColor visual_def_return, exact_def_return;
-   XEvent event;
    int o_argc = argc;
    char **o_argv = argv;
    int i,j;

--- 48,53 -----
    char *foreground = NULL, *background = NULL, *border = NULL;
    char *geomstring = NULL;
    XColor visual_def_return, exact_def_return;
    int o_argc = argc;
    char **o_argv = argv;
    int i;
***************
*** 52,58
    XEvent event;
    int o_argc = argc;
    char **o_argv = argv;
!   int i,j;
    char *basename;
    int width, height;
    int mapped=0;

--- 50,56 -----
    XColor visual_def_return, exact_def_return;
    int o_argc = argc;
    char **o_argv = argv;
!   int i;
    char *basename;
    int width, height;
    int mapped=0;
***************
*** 63,69
    char *bitmapfilename = "chaos.xbm";
    char *pointlist = NULL;
    int manpoints = 0;
!   double time();
  
    progname = argv[0];
  

--- 61,70 -----
    char *bitmapfilename = "chaos.xbm";
    char *pointlist = NULL;
    int manpoints = 0;
!   int npoints = 3;
!   double mulcon = 0.5;
!   long time(), atol();
!   char *strrchr();
  
    progname = argv[0];
  
***************
*** 71,77
    else basename=progname;
  
    while (--argc>0) {
!     char *option = (*++argv);
      if (!strcmp(option,"-delay")) {
        if (--argc==0) usage();
        delayvalue = atol(*++argv);

--- 72,78 -----
    else basename=progname;
  
    while (--argc>0) {
!     char *option = (*++argv), *strchr();
      if (!strcmp(option,"-delay")) {
        if (--argc==0) usage();
        delayvalue = atol(*++argv);
***************
*** 106,111
        bwidth = atoi(*++argv);
        if (bwidth<0) bwidth = 0;
      }
      else if (!strcmp(option,"-geometry")) {
        if (--argc==0) usage();
        geomstring = (*++argv);

--- 107,118 -----
        bwidth = atoi(*++argv);
        if (bwidth<0) bwidth = 0;
      }
+     else if (!strcmp(option,"-dist")) {
+       double atof();
+       if (--argc==0) usage();
+       mulcon = atof(*++argv);
+       if (mulcon < 0.0) mulcon = -mulcon;
+     }
      else if (!strcmp(option,"-geometry")) {
        if (--argc==0) usage();
        geomstring = (*++argv);
***************
*** 132,138
      char *calloc(), *strchr();
      double strtod();
      int commacount = 0;
-     int len;
      while (*temp != '\0') commacount += (*(temp++) == ',') ? 1 : 0;
      if (!(commacount & 0x1)) usage();
      npoints = (commacount >> 1) + 1;

--- 139,144 -----
      char *calloc(), *strchr();
      double strtod();
      int commacount = 0;
      while (*temp != '\0') commacount += (*(temp++) == ',') ? 1 : 0;
      if (!(commacount & 0x1)) usage();
      npoints = (commacount >> 1) + 1;
***************
*** 337,343
  	  int fd = ConnectionNumber(display);
  	  int readfds = 1<<fd;
  	  long delay = mapped ? delayvalue : udelayvalue;
!           getnextpoint(&x, &y, &ix, &iy, width, height);
            XFillRectangle(display, win, wingc, ix, iy, 1, 1);
            XFillRectangle(display, bitmap, bitmapgc2, ix, iy, 1, 1);
  	  if (mapped) XFlush(display);

--- 343,349 -----
  	  int fd = ConnectionNumber(display);
  	  int readfds = 1<<fd;
  	  long delay = mapped ? delayvalue : udelayvalue;
!           getnextpoint(&x, &y, &ix, &iy, width, height, npoints, mulcon);
            XFillRectangle(display, win, wingc, ix, iy, 1, 1);
            XFillRectangle(display, bitmap, bitmapgc2, ix, iy, 1, 1);
  	  if (mapped) XFlush(display);
***************
*** 348,354
          else {
  	  XRectangle rects[DOTSPERCALL];
  	  for (i=0; i<DOTSPERCALL; i++) {
!             getnextpoint(&x, &y, &ix, &iy, width, height);
  	    rects[i].x = ix;
  	    rects[i].y = iy;
  	    rects[i].width = 1;

--- 354,360 -----
          else {
  	  XRectangle rects[DOTSPERCALL];
  	  for (i=0; i<DOTSPERCALL; i++) {
!             getnextpoint(&x, &y, &ix, &iy, width, height, npoints, mulcon);
  	    rects[i].x = ix;
  	    rects[i].y = iy;
  	    rects[i].width = 1;
***************
*** 409,415
    }
  }
  
! getnextpoint(x, y, ix, iy, width, height)
  double *x, *y;
  int *ix, *iy;
  int width, height;

--- 415,421 -----
    }
  }
  
! getnextpoint(x, y, ix, iy, width, height, npoints, mulcon)
  double *x, *y;
  int *ix, *iy;
  int width, height;
***************
*** 413,418
  double *x, *y;
  int *ix, *iy;
  int width, height;
  {
    long rndm();
    int dest;

--- 419,426 -----
  double *x, *y;
  int *ix, *iy;
  int width, height;
+ int npoints;
+ double mulcon;
  {
    long rndm();
    int dest;
***************
*** 417,424
    long rndm();
    int dest;
    dest = (int)rndm((long)npoints);
!   *x = (fpoints[dest].x + *x)/2.0;
!   *y = (fpoints[dest].y + *y)/2.0;
    *ix = (int)(*x * width + .5);
    *iy = (int)(*y * height + .5);
  }

--- 425,432 -----
    long rndm();
    int dest;
    dest = (int)rndm((long)npoints);
!   *x = (fpoints[dest].x - *x) * mulcon + *x;
!   *y = (fpoints[dest].y - *y) * mulcon + *y;
    *ix = (int)(*x * width + .5);
    *iy = (int)(*y * height + .5);
  }
***************
*** 432,437
      "[-bw <borderwidth>]",
      "[-delay <msec>]",
      "[-display <displayname>]",
      "[-geometry <geometry>]",
      "[-mpoints]",
      "[-out <bitmapfile>]",

--- 440,446 -----
      "[-bw <borderwidth>]",
      "[-delay <msec>]",
      "[-display <displayname>]",
+     "[-dist <distance>]",
      "[-geometry <geometry>]",
      "[-mpoints]",
      "[-out <bitmapfile>]",





*** orig-patchlevel.h	Tue Mar  7 09:24:55 1989
--- patchlevel.h	Tue Mar  7 09:24:30 1989
***************
*** 1
! #define PATCHLEVEL 0

--- 1 -----
! #define PATCHLEVEL 1
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x