v12i073: xmartin - son of xfroot, Part01/01

Ed Kubaitis - CSO ejk at ux2.cso.uiuc.edu
Wed May 1 05:08:37 AEST 1991


Submitted-by: Ed Kubaitis - CSO  <ejk at ux2.cso.uiuc.edu>
Posting-number: Volume 12, Issue 73
Archive-name: xmartin/part01

xmartin 1.1

Xmartin is a root window decorator based on the Barry Martin hopalong
algorithms. It has many features beyond those in its predecessor xfroot.
This version is at patchlevel 1 which includes support for the tvtwm
window manager.

-----Cut here-----------------------------------------------------------------
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 04/28/1991 11:09 UTC by ejk at ux2
# Source directory /u/ejk/xmartin
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   4898 -rw-r--r-- README
#    145 -rw-r--r-- Imakefile
#     21 -rw-r--r-- patchlevel.h
#   6772 -rw-r--r-- xmartin+.pl
#  18908 -rw-r--r-- xmartin.c
#   5884 -rw-r--r-- xmartin.man
#    480 -rw-r--r-- xmartin.mk
#
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
	echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
XXmartin 1.1 - son of xfroot - 25 April 1991
X-------------------------------------------
X
XDISCLAIMER: This software is provided "as is" and with no warranties 
X	    of any kind.
X
XXmartin is an X11 root window decorator based on the Barry Martin hopalong
Xalgorithms (see A. K. Dewdney's column in the 9/86 Scientific American.)
XIt adds these features to those in its xfroot predecessor:
X
X   o new patterns with three variations on the original Martin hopalong
X   o option for tiling effects and/or speed
X   o option for effects by periodically perturbing (x,y)
X   o random color sequences and tailorable resources for colors
X   o ranges for hopalong parameters
X   o zoom and pan options 
X   o option to recall and alter previous hopalong parameters
X   o optional Perl xmartin+ tailors probabilities, replays interesting patterns
X   o tvtwm support (courtesy of Kevin Meek & Ranjan Bagchi)
X
X
XInstallation Instructions
X-------------------------
XThe materials include both an Imakefile and a simple makefile (xmartin.mk).
XReview the one you intend to use and make any changes needed for your 
Xenvironment. 
X
XXmartin is very floating-point intensive. Be sure to include in CFLAGS
Xany options to improve floating-point performance (eg: -f68881 on Sun 3's.)
X
XIf your system does not have perl(1) installed, you may want to comment out
Xthe lines having to do with "xmartin+". If you have perl but it is not in 
X/usr/bin/perl, modify the first line of xmartin+.pl. [About perl: perl is a 
Xlanguage devised by Larry Wall with most of the features of new awk, shell 
Xscripts, and C -- sort of one-stop shopping for things you don't want to do 
Xin C. It has it's own newsgroup (comp.lang.perl) and O&A Nutshell book: 
XProgramming Perl (info: 1-800-338-6887.) The source is freely available 
X(jpl-devvax.jpl.nasa.gov in pub/perl.4.0/kits at 0). It builds easily on most 
Xun*x platforms and can usually be coaxed on the others.]
X
XIf you find it necessary to modify the source code to get xmartin to compile 
Xor execute correctly, I'd appreciate hearing about the problem and what you 
Xdid to get around it. I'd also appreciate hearing about success on platforms
Xother than those below.
X
XXmartin has been built & tested on the following client platforms:
X
X    o IBM RS/6000 540 AIX 3.1 - 3003 (X11R4 & X11R3) Perl 4.0
X    o Convex 240 9.1 OS (X11R4) Perl 3.044
X    o Sequent Symmetry S81 Dynix 3.0.17.7 (X11R4) Perl 4.0
X    o Sun 3/50 SunOS 3.5 (X11R4)
X    o Sun 3/60 SunOS 4.1 (X11R4)
X    o VaxServer 3500 BSD 4.3/Reno gcc (X11R4) Perl 3.37
X    o Apollo 425t DomainOS 10.3.4 unoptimized cc (X11R3) 
X    o VaxServer 3500 Ultrix-32 V3.0(Rev 64) (X11R4) Perl 3.15
X    o Cray 2 Unicos scc (X11R3)
X
XAnd with the following servers:
X
X    o NCD 19 monochrome - X11R3
X    o Sun 3/50 monochrome - X11R4
X    o Sun 3/60 color - X11R4
X    o Visual Turbo X-19 grayscale - X11R4
X    o IBM Xstation 120 grayscale - X11R3
X    o IBM Xstation 120 color - X11R3
X
X
XUsing xmartin
X-------------
XAfter installation, the unadorned command 'xmartin' should set your root 
Xwindow to one of the roughly 1e50 basic hopalong patterns. Review the man 
Xpage for options you may want to try. 'xmartin help' or 'xmartin+ help' 
Xyield a concise synopsis of options.
X
XOn clients without strong floating point performance, you might try '-tile'
Xand/or '-dynam'. -tile greatly reduces calculation time. -dynam, although 
Xincreasing elapsed time, reduces "psychological" time by letting you watch
Xthe pattern emerge as the calculation progresses.
X
XIf you have perl, executing xmartin+ will create a ~/.xmartin+ file with
Xseveral sets of xmartin parameters you can request by name with
X
X	      xmartin+ -n name
X
X'xmartin+ -q' lists the names available. 'xmartin+ -demo' will invoke
Xxmartin (using -dynam) once for each name.  (If you don't have perl, you 
Xcan peek at these parameter sets in the xmartin+.pl source.) I'd appreciate
Xhearing about any interesting parameter sets you discover.
X
XXmartin does not distinguish between color and grayscale displays. On the
Xlatter, you might try '-mono' if you don't care for the color -> grayscale
Xmapping effect. 
X
X
XQuote
X-----
XMartin (whom I've never met) said this about his discovery:
X
X       Clearly these curious configurations show us that the 
X       rules responsible for the construction of elaborate 
X       living tissue structures could be absurdly simple.
X
X
X----------------------------------
XEd Kubaitis (ejk at ux2.cso.uiuc.edu)
XComputing Services Office - University of Illinois, Urbana
X
X
X==============================================================================
XXmartin Revision History
X------------------------
X
Xxmartin 1.1 (patchlevel 1)
X--------------------------
X   o tvtwm (Tom's Virtual Tab Window Manager) support
X   o fix test for color display in xmartin.c hopalong()
X   o minor code & documentation cleanup
X
Xxmartin 1.0 (patchlevel 0)
X--------------------------
X   o Initial release
SHAR_EOF
chmod 0644 README ||
echo 'restore of README failed'
Wc_c="`wc -c < 'README'`"
test 4898 -eq "$Wc_c" ||
	echo 'README: original size 4898, current size' "$Wc_c"
fi
# ============= Imakefile ==============
if test -f 'Imakefile' -a X"$1" != X"-c"; then
	echo 'x - skipping Imakefile (File already exists)'
else
echo 'x - extracting Imakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
XDEPLIBS = $(DEPXLIB)
XLOCAL_LIBRARIES = $(XLIB)
XSYS_LIBRARIES = -lm
X
XSimpleProgramTarget(xmartin)
XInstallProgram(xmartin+.pl, $(BINDIR)/xmartin+)
SHAR_EOF
chmod 0644 Imakefile ||
echo 'restore of Imakefile failed'
Wc_c="`wc -c < 'Imakefile'`"
test 145 -eq "$Wc_c" ||
	echo 'Imakefile: original size 145, current size' "$Wc_c"
fi
# ============= patchlevel.h ==============
if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
	echo 'x - skipping patchlevel.h (File already exists)'
else
echo 'x - extracting patchlevel.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
X#define PATCHLEVEL 1
SHAR_EOF
chmod 0644 patchlevel.h ||
echo 'restore of patchlevel.h failed'
Wc_c="`wc -c < 'patchlevel.h'`"
test 21 -eq "$Wc_c" ||
	echo 'patchlevel.h: original size 21, current size' "$Wc_c"
fi
# ============= xmartin+.pl ==============
if test -f 'xmartin+.pl' -a X"$1" != X"-c"; then
	echo 'x - skipping xmartin+.pl (File already exists)'
else
echo 'x - extracting xmartin+.pl (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xmartin+.pl' &&
X#! /usr/bin/perl
X#
X#   xmartin+ - front end to the xmartin root window decorator
X#
X#   xmartin+ [-q] [-demo] [-n name] [-f file] [xmartin-options]
X
X$File = "$ENV{'HOME'}/.xmartin+";
X$xmNoArg ="^-(mono|nrc|v)$";
X$xmArg = "^-(p|P|a|b|c|nc|zoom|move|display)$";
X$xmOptArg = "^-(dynam|tile|perturb)$";
X
X#---parse arguments------------------------------------------------------------
X
Xwhile($_ = shift) {
X   if    (m!^-n$!) { $n = shift; &usage unless $n; push(@Names,$n); }
X   elsif (m!^-file$!) { $File = shift; &usage unless $File; }
X   elsif (m!^-q$!) { $Query++; }
X   elsif (m!^-demo$!) { $Demo++; }
X   else {
X      if    (m!$xmNoArg!)  { $xmOpts .= "$_ "; }
X      elsif (m!$xmArg!)    { $xmOpts .= "$_ " . shift . ' '; }
X      elsif (m!$xmOptArg!) {
X	 $xmOpts .= "$_ ";
X	 if ($ARGV[0] !~ /^-/ ) { $xmOpts .= shift . ' '; }
X	 }
X      else { &usage; }
X      }
X   }
X
X&initfile unless -s $File;
X
X#---read file, concatenate continuation lines ---------------------------------
X
Xopen(File, $File) || die "xmartin+: can't open $File: $!\n";
Xwhile(<File>) { $text .= $_; }
X$* = 1; $text =~ s/\\\s*\n//g; @Lines = split(/\n/, $text); $* = 0;
X
X#---parse file, extract entries------------------------------------------------
X
Xfor(@Lines) {
X   $line = $_;
X   #---trim/skip comments
X   s/#.*$//; next if m!^\s*$!;
X   #---remove extraneous white space
X   s/^\s+//; s/\s+$//; s/\s+(:)/$1/g; s/(:)\s+/$1/g; s/\s+/ /g;
X   #---check syntax
X   m!^\S+:.*:\d+\.?\d*:\S! || die "xmartin+: invalid entry in $File:\n$line";
X   #---extract and record fields
X   m!([^:]*):([^:]*):([^:]*):(.*)!;
X   $name = $1; $comment = $2; $weight = $3; $parms = $4;
X   $Sum_weight += $weight;
X   $Comment{$name} = $comment;
X   $Weight{$name} = $weight;
X   #---check if reference to previous entry
X   if ($parms =~ /{(.*)}/ ) {
X      $pname = $1; $pname =~ s/\s//g;
X      if (!$Parms{$pname}) {
X	 warn "xmartin+: no previous entry {$pname} for this line:\n";
X	 die "$line\n";
X	 }
X      $parms =~ s/{.*}/$Parms{$pname}/;
X      }
X   $Parms{$name} = $parms;
X   }
X
X#---If query, print out names-weights-comments and exit----------------------
X
Xif ($Query) {
Xformat top =
XName----------  Weight Comment---------------------------------------------
X.
Xformat STDOUT =
X@<<<<<<<<<<<<<  @>>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
X$_,              $weight, $Comment{$_}
X.
X   for (sort keys(%Weight)) { $weight = $Weight{$_} ? $Weight{$_} : ''; write; }
X   exit(0);
X   }
X
X#---If demo, set to execute each entry once with -dynam------------------------
X
Xif ($Demo) {
X   $xmOpts .= '-dynam';
X   for (sort keys(%Parms)) { push(@Names, $_); }
X   }
X
X#---if specific entries not requested, select one randomly---------------------
X
Xif ($#Names < 0) {
X   $Sum_weight > 0 || die "xmartin+: no $File entries with non-zero weight\n";
X   srand(); $Random = rand($Sum_weight);
X   for(keys %Weight) {
X      $weight = $Weight{$_};
X      next unless $weight > 0;
X      $sum_weight += $weight;
X      next if $sum_weight < $Random;
X      push(@Names, $_); last;
X      }
X   }
X
X#---generate/execute xmartin call(s)--------------------------------------------
X
Xfor $n(@Names) {
X   $Parms{$n} || die qq|xmartin+: No entry found in $File for "-n $n"\n|;
X   }
Xfor $n(@Names) {
X   print "xmartin+: $n $Comment{$n}\n";
X   $cmd = "xmartin $Parms{$n} $xmOpts";
X   print "$cmd\n";
X   system($cmd);
X   }
X
X#---initfile - set up default .xmartin+ file-----------------------------------
X
Xsub initfile {
X   warn "xmartin+: Setting up default xmartin+ file in $File\n";
X   warn "xmartin+: You may want to read the comments in this file.\n";
X   open (File, ">$File") || die "xmartin+: can't open $File:$!\n";
X   print File <<EOF;
X#
X#  xmartin+ tailoring file
X#
X#  Entries in this file are used by the xmartin+ front end to generate an
X#  xmartin call tailored to suit your preferences. Entry format:
X#
X#     <name>:<comment>:<weight>:<xmartin-parms>
X#
X#     <name> : a name for the entry. Used in "xmartin+ -n name".
X#
X#     <comment>: a brief comment describing the entry
X#
X#     <weight> : any positive numerical value. The weight divided by the 
X#                sum of the weights for all entries is the probability 
X#                that xmartin+ will select this entry. A weight of 0 can
X#                be used to record interesting parameters for recall by
X#                name.
X#
X#     <xmartin-parms> : the xmartin parameters for this entry. You can
X#                       include the parameters of a previously defined
X#                       entry by placing the name of the entry in braces
X#                       "{}" in the parms field of a subsequent entry.
X#            
X#  The default file has entries matching the random parameters used by 
X#  xmartin itself. (Except "-tile" for the smallish martin2 patterns.)
X#
X
Xmartin1 :(square root): 48 : -f martin1 -a 40::1540  -b 3::20  -c  100::3100 
Xmartin2 :(sin)        :  2 : -f martin2 -a  3.075927::3.215927 -tile
Xejk1    :(linear)     : 40 : -f ejk1 -a -500:500  -b  -0.4:+0.4  -c 10::110
Xejk2    :(log)        : 10 : -f ejk2  #can't do xmartin non-linear abc defaults
X
Xjigsaw    :(perturbed martin2): 0 : -f martin2 -perturb 100,100
Xcanvas    :(perturbed martin2): 0 : -f martin2 -perturb 20,80
Xflag      :(perturbed martin2): 0 : -f martin2 -perturb 100,1 -zoom 80
Xangelhair :(perturbed martin2): 0 :\\
X	   -f martin2 -perturb 5,1.6 -zoom 120 -move 140,250 -a -3.07:-3.18
Xdebris    :(perturbed martin2): 0 : {angelhair} -a -3.20:-3.25
X
X4lobe     :(ejk1 subset): 0 : -f ejk1 -a 205:215 -b 0.39:0.40 -c 35:45
Xnucleus   :(ejk1 subset): 0 : -f ejk1 -a -30:-50 -b -.13:-.14 -c 50::70
Xshards    :(ejk1 subset): 0 : -f ejk1 -a 125:130 -b 1 -c 60:70 -zoom 0.2
Xpeacock   :(ejk1 subset): 0 : -f ejk1 -a 125:128 -b 1.05 -c 60:65 -zoom 0.2
Xneuron    :(ejk1 subset): 0 :\\
X	   -f ejk1 -a 130:140 -b -1.1  -c -55:-65 -zoom 0.1 -nc 2000 -P 250000
Xpropeller :(ejk1 subset): 0 :\\
X	   -f ejk1 -a 175:185 -b -0.28:-0.31 -c -40:-50 -zoom 0.2
Xdragonfly :(ejk1 subset): 0 :\\
X           -f ejk1 -a 400:500 -b 1.4:1.5  -c -40:-60 -zoom 0.02 -move ne,200
Xbutterfly :(ejk1 subset): 0 :\\
X           -f ejk1 -a 140:200 -b .69:.70 -c -190:-200 -zoom 0.04 -p 100000
Xparkayfly :(ejk1 subset): 0 : {butterfly} -perturb 
XEOF
X   }
X
X#---usage - explain usage & exit-----------------------------------------------
X
Xsub usage { 
X   print STDERR <<EOF;
Xusage: xmartin+ [-q] [-demo] [-n name] [-file file] [xmartin-options]
X
X       -q:    prints table of entry names, weights, & comments
X       -demo: executes (using -dynam) every entry
X
X       name: name of an entry in an xmartin+ tailoring file
X       file: name of xmartin+ tailoring file [default: ~/.xmartin+]
X
X       xmartin-options: xmartin(1) options (except -f & -recall) to
X			add to or alter those generated by xmartin+
XEOF
X   exit(1);
X   }
SHAR_EOF
chmod 0644 xmartin+.pl ||
echo 'restore of xmartin+.pl failed'
Wc_c="`wc -c < 'xmartin+.pl'`"
test 6772 -eq "$Wc_c" ||
	echo 'xmartin+.pl: original size 6772, current size' "$Wc_c"
fi
# ============= xmartin.c ==============
if test -f 'xmartin.c' -a X"$1" != X"-c"; then
	echo 'x - skipping xmartin.c (File already exists)'
else
echo 'x - extracting xmartin.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xmartin.c' &&
X/*
X *   xmartin - set root window to Martin hopalong pattern
X *
X *   xmartin [-f {martin1|martin2|ejk1|ejk2}]
X *           [-p npoints] [-P npoints] 
X *           [-a value[:[:]value]] [-b value[:[:]value]] [-c value[:[:]value]]
X *           [-color] [-nc npoints] [-dynam] [-nd npoints] 
X *           [-tile [XxY]] [-perturb [n[,v]]] 
X *           [-zoom real] [-move d,p]
X *           [-recall] [-display display]
X *           [-v]
X *
X *   -f function : martin1|martin2|ejk1|ejk2   [random]
X *   -p npoints  : maximum in-range points   [25% of display/tile pixels]
X *   -P npoints  : maximum total points to calculate   [3 x -p value]
X *   -a -b -c    : real values for hopalong parameters   [random]
X *   -dynam [nd] : dynamic display, flush after nd points   [1024, 128 if -tile]
X *   -tile [XxY] : tiling factors   [random if XxY omitted]
X *   -perturb [n,v] : perturb (x,y) every n points by v  [random if n,v omitted]
X *   -zoom real  : zoom factor   [1.0, 4.0 if martin2]
X *   -move d,p   : moves pattern p pixels in direction d. d is a compass
X *                 heading in degrees or 'n', 'sw', 'nnw' etc
X *   -recall     : recall f, abc, zoom, move, & perturb values from last plot
X *   -nrc        : turns off randomizing of color sequences
X *   -nc npoints : points calculated before color change   [(-P value)/ncolors]
X *   -mono       : forces white-on-black for grayscale or color displays
X *   -v          : print version & patchlevel
X *
X *   Color takes more processor time & memory than monochrome. Dynamic display
X *   takes more processor time and client/server bandwidth than static.
X *   Tiling reduces processor time, memory, and bandwidth.
X *     
X *   Hopalong was attributed to Barry Martin of Aston University (Birmingham, 
X *   England) by A. K. Dewdney in the 9/86 Scientific American. The Ranf 
X *   portable random number generator is based on work by D. H. Lehmer, Knuth, 
X *   David Sachs(Fermilab) and Curt Canada(NCSA).
X *
X *   This software is provided "as is" and with no warranties of any kind.
X *
X *   Ed Kubaitis
X *   Computing Services Office
X *   University of Illinois, Urbana
X */
X
X#include <X11/Xos.h>
X#include <X11/Xlib.h>
X#include <X11/Xatom.h>
X#include <math.h>
X#include <stdio.h>
X#include "patchlevel.h"
X
X#define Martin1 0
X#define Martin2 1
X#define Ejk1 2
X#define Ejk2 3
X#define Nfunc 4
Xint Function = -1;
Xchar fname[Nfunc][16] = { "martin1", "martin2", "ejk1", "ejk2" };
X
Xint     mxp=0, np=0;             /* max in-range points, in-range points    */
Xint     mxP=0, nP=0;             /* max total points,    total points       */
Xint     nC=0, nc=0;              /* color-change interval (points)          */
Xint     nD=0, nd=0;              /* dynam flush buffer interval (points)    */
Xint     Pn=0, pn=0;              /* seed perturbation interval (points)     */
Xdouble  Pv=0;                    /* seed perturbation value                 */
X
Xdouble  A=0, B=0, C=0;           /* hopalong parameters                     */
Xdouble  A1=0, B1=0, C1=0;        /* 2nd part of parameter range             */
Xdouble  Af=0, Bf=0, Cf=0;        /* plus-or-minus parameter range flag      */
Xint     Color=0;                 /* non-zero if color                       */
Xint     Randomcolor=1;           /* non-zero for randomized color sequences */
Xint     Dynam=0;                 /* non-zero for dynamic plotting           */
Xint     Tx=1, Ty=1;              /* tile factors                            */
Xdouble  Zf=0;                    /* magnification factor                    */
Xint     Recall=0;                /* non-zero if previous parms recalled     */
X
Xint wc, cx, cy, ix, iy, mxX, mxY, color, plane, offset, pixel, pix, bit, col;
Xdouble x, y, x1;
X
X#define Min(x,y) ((x < y)?x:y)
X#define Max(x,y) ((x > y)?x:y)
X
X#define Ranf() (double)((Ranfseed=(Ranfseed*1629+1)%1048576)/1048576.)
X#define Ranfset(l) (Ranfseed=(((abs(l)%1048576)*1629)+1)%1048576)
Xlong    Ranfseed=4326;
X
X#define Ncolors 16
Xstruct colors {
X   unsigned long c_color;
X   double c_rand;
X   } colors[Ncolors];
Xchar color_names[Ncolors][30] = { "red", "green", "blue", "yellow", "magenta", 
X   "cyan", "coral", "slate blue", "orange red", "spring green", "orange", 
X   "steel blue", "pink", "violet", "firebrick", "gold"};
X
Xchar compass[16][4] = {
X   "n", "nne", "ne", "ene", "e", "ese", "se", "sse",
X   "s", "ssw", "sw", "wsw", "w", "wnw", "nw", "nnw" };
X
XAtom __SWM_VROOT = None;
XDisplay *dpy = NULL;       
Xint     W, H, D;   
XWindow  w_root; 
XWindow rootReturn, parentReturn, *children;
Xunsigned int numChildren;
XXImage  *xi;
XPixmap  pixmap;
XGC      gc;
XXGCValues gcv;
XXPoint  *xpoints;
Xchar    *bmap;
Xint     bmn, t0;
Xchar    Savefile[128]; FILE *sf;
Xchar    *Move = NULL;
Xchar    **Argv = NULL; int Argc = 0;
X
X
Xmain(argc, argv) int argc; char *argv[]; {
X
X   preset(argc, argv);
X   hopalong();
X   finish();
X
X   }
X
X
Xhopalong() {
X
X   if (Function == Martin1) {
X      if (!A) { A = 40 + Ranf()*1500;  if (Ranf()<0.5) A = -A; }
X      if (!B) { B = 3  + Ranf()*17;    if (Ranf()<0.5) B = -B; }
X      if (!C) { C = 100 + Ranf()*3000; if (Ranf()<0.5) C = -C; }
X      fprintf(stderr, "xmartin: A:%g  B:%g  C:%g\n", A, B, C);
X      }
X   else if (Function == Martin2) {
X      if (!A) { A = 3.075927 + Ranf()*0.14; if (Ranf()<0.5) A = -A; }
X      fprintf(stderr, "xmartin: A:%g\n", A);
X      }
X   else if (Function == Ejk1) {
X      if (!A) { A =        Ranf()*500; if (Ranf()<0.5) A = -A; }
X      if (!B) { B =        Ranf()*.40; if (Ranf()<0.5) B = -B; }
X      if (!C) { C =   10 + Ranf()*100; if (Ranf()<0.5) C = -C; }
X      fprintf(stderr, "xmartin: A:%g  B:%g  C:%g\n", A, B, C);
X      }
X   else if (Function == Ejk2) {
X      if (!A) { A = Ranf()*500;          if (Ranf()<0.5) A = -A; }
X      if (!B) { B = pow(10.,6+Ranf()*24); if (Ranf()<0.5) B = -B; }
X      if (!C) { C = pow(10.,  Ranf()*9);  if (Ranf()<0.5) C = -C; }
X      fprintf(stderr, "xmartin: A:%g  B:%g  C:%g\n", A, B, C);
X      }
X
X   while (++nP < mxP) {
X
X      if (Function == Ejk1) {
X	 x1 = y  - ( (x>0) ? (B*x-C) : -(B*x-C) );
X	 y = A - x; x=x1;
X	 }
X      else if (Function == Martin1) {
X	 x1 = y  - ( (x<0) ? sqrt(fabs(B*x-C)) : -sqrt(fabs(B*x-C)) );
X	 y = A - x; x=x1;
X	 }
X      else if (Function == Ejk2) {
X	 x1 = y  - ( (x<0) ? log(fabs(B*x-C)) : -log(fabs(B*x-C)) );
X	 y = A - x; x=x1;
X	 }
X      else if (Function == Martin2) {
X	 x1 = y  - sin(x);
X	 y = A - x; x=x1;
X	 }
X
X      if (Pn && ++pn > Pn) {
X	 x += (x>0) ? -Pv : Pv;
X	 y += (y>0) ? -Pv : Pv;
X	 pn = 0;
X	 }
X
X      if (Color && ++nc > nC) {
X	 if (Dynam) {
X	    col = (col+1)%Ncolors;
X	    XSetForeground(dpy, gc, colors[col].c_color);
X	    }
X	 else {
X	    color = (color+1)%Ncolors;
X	    pixel=colors[color].c_color;
X	    }
X	 nc = 0;
X	 }
X
X      iy = cy + Zf*y; if (iy < 0 || iy > mxY) continue;
X      ix = cx + Zf*x; if (ix < 0 || ix > mxX) continue;
X
X      if (Dynam) {
X	 xpoints[nd].x = ix;
X	 xpoints[nd].y = iy;
X	 if (++nd == nD) {
X	    XDrawPoints(dpy, pixmap, gc, xpoints, nd, CoordModeOrigin);
X	    XClearWindow(dpy, w_root);
X	    nd = 0;
X	    }
X	 }
X      else if (Color) {
X/*       XPutPixel(xi, ix, iy, colors[color].c_color);  */    /* very slow */
X	 pix = pixel;
X	 for(plane=D-1; plane>=0; plane--) {
X	    bit = pix & 1;
X	    offset=plane*(wc)*H + iy*wc +(ix>>3);
X	    bmap[offset] &= ~(1<<(ix&7));
X	    if (bit) bmap[offset] |= 1<<(ix&7);
X	    pix >>= 1;
X	    }
X	 }
X      else { bmap[iy*wc+(ix>>3)] |= 1<<(ix&7); }
X
X      if (++np >= mxp) break;
X      }
X   }
X
X
Xfinish() {
X   int i;
X
X   if (nd) { 
X      XDrawPoints(dpy, pixmap, gc, xpoints, nd, CoordModeOrigin); 
X      XClearWindow(dpy, w_root);
X      } 
X
X   if (!Dynam) {
X      if (D == 1 && BlackPixel(dpy,0)) 
X	 for (i=(D-1)*H*((W+7)/8); i<D*H*((W+7)/8); i++)  bmap[i] ^= 0377; 
X      gcv.background = BlackPixel(dpy, 0);
X      gcv.foreground = WhitePixel(dpy, 0);
X      gc = XCreateGC(dpy, w_root, GCBackground|GCForeground, &gcv);
X      pixmap = XCreatePixmap( dpy, w_root, W, H, D);
X      if (!pixmap) {fprintf(stderr,"xmartin: XCreatePixmap error\n"); exit(1);}
X      XPutImage(dpy, pixmap, gc, xi, 0, 0, 0, 0, W, H);
X      XSetWindowBackgroundPixmap(dpy, w_root, pixmap);
X      XDestroyImage(xi);
X      }
X
X   XFreeGC(dpy, gc);
X   XFreePixmap(dpy, pixmap);
X   XClearWindow(dpy, w_root);
X   XFlush(dpy);
X   XCloseDisplay(dpy);
X
X   printf("xmartin: %d points   %d(%d%%) in-range   %d seconds\n",
X	  nP, np, (100*np)/nP, time(0) - t0);
X
X   if (!Recall) {
X      sf = fopen(Savefile, "w");
X      if (!sf) { perror("xmartin: ~/.xmartin"); exit(1); }
X      fprintf(sf, "-f\n%s\n-zoom\n%.17e\n-a\n%.17e\n", fname[Function], Zf, A);
X      if (B) fprintf(sf, "-b\n%.17e\n", B);
X      if (C) fprintf(sf, "-c\n%.17e\n", C);
X      if (Pn) fprintf(sf, "-perturb\n%d,%.17e\n", Pn, Pv);
X      if (Move) fprintf(sf, "-move\n%s\n", Move);
X      fclose(sf);
X      }
X   }
X
X
Xpr_Argv(s) char *s; {
X   Argv = (Argc) ? (char **) realloc ((char *)Argv, (Argc+1) * sizeof(char *))
X                 : (char **) malloc  (sizeof(char *));
X   Argv[Argc++] = (s) ? strcpy((char *) malloc (strlen(s)+1), s) : NULL;
X   }
X
X
Xpr_sortcolors(a,b) struct colors *a, *b; { 
X   double d = a->c_rand - b->c_rand;
X   if (d < 0) return(-1);
X   else if (d > 0) return(1);
X   else return(0);
X   }
X
Xextern char *getenv();
X
Xpreset(argc, argv) int argc; char *argv[]; {
X   char *display = getenv("DISPLAY"), dir[4], **argv0 = argv, buf[80];
X   int  i, k, mono = 0, argc0 = argc, dist = 0;
X   double degr = 0, pi;
X
X   t0 = time(0); Ranfset(t0);
X   pi = 4 * atan(1.0);
X   strcpy(Savefile, getenv("HOME"));
X   strcat(Savefile, "/.xmartin");
X
X   /* prescan arguments for "-recall" */
X
X   while (++argv, --argc > 0) { 
X      if (!strcmp(*argv, "-recall")) {
X	 sf = fopen(Savefile, "r");
X	 if (!sf) { perror("xmartin: ~/.xmartin"); exit(1); }
X	 while(fgets(buf, 80, sf)) {
X	    buf[strlen(buf)-1] = '\0';
X	    pr_Argv(buf);
X	    }
X	 Recall++;
X	 break;
X	 }
X      }
X   while (++argv0, --argc0 > 0) { pr_Argv(*argv0); }
X
X
X   /*  parse arguments */
X
X   for (i=0; i<Argc; i++) {
X      if (!strcmp(Argv[i], "-p")) {
X	 if (++i>=Argc) usage();
X	 if(!sscanf(Argv[i], "%d", &mxp)) usage();
X	 if (mxp <= 0) usage();
X	 }
X      else if (!strcmp(Argv[i], "-P")) {
X	 if (++i>=Argc) usage();
X	 if(!sscanf(Argv[i], "%d", &mxP)) usage();
X	 if (mxP <= 0) usage();
X	 }
X      else if (!strcmp(Argv[i], "-a")) {
X	 if (++i>=Argc) usage();
X	 if      ( sscanf(Argv[i], "%lf::%lf", &A, &A1) == 2) { Af++; }
X	 else if ( sscanf(Argv[i], "%lf:%lf",  &A, &A1) == 2) {;}
X	 else if (!sscanf(Argv[i], "%lf",      &A, &A1))      { usage();}
X	 }
X      else if (!strcmp(Argv[i], "-b")) {
X	 if (++i>=Argc) usage();
X	 if      ( sscanf(Argv[i], "%lf::%lf", &B, &B1) == 2) { Bf++; }
X	 else if ( sscanf(Argv[i], "%lf:%lf",  &B, &B1) == 2) {;}
X	 else if (!sscanf(Argv[i], "%lf",      &B, &B1))      { usage();}
X	 }
X      else if (!strcmp(Argv[i], "-c")) {
X	 if (++i>=Argc) usage();
X	 if      ( sscanf(Argv[i], "%lf::%lf", &C, &C1) == 2) { Cf++; }
X	 else if ( sscanf(Argv[i], "%lf:%lf",  &C, &C1) == 2) {;}
X	 else if (!sscanf(Argv[i], "%lf",      &C, &C1))      { usage();}
X	 }
X      else if (!strcmp(Argv[i], "-mono")) {
X	 mono++;
X	 }
X      else if (!strcmp(Argv[i], "-nrc")) {
X	 Randomcolor = 0;
X	 }
X      else if (!strcmp(Argv[i], "-dynam")) {
X	 Dynam++;
X	 if      ( (i+2)> Argc || Argv[i+1][0] == '-') {;}
X	 else if (!sscanf(Argv[++i], "%d", &nD))       {usage();}
X	 }
X      else if (!strcmp(Argv[i], "-nc")) {
X	 if (++i>=Argc) usage();
X	 if(!sscanf(Argv[i], "%d", &nC)) usage();
X	 if (nC <= 0) usage();
X	 }
X      else if (!strcmp(Argv[i], "-f")) {
X	 if (++i>=Argc) usage();
X	 while(++Function < Nfunc){ 
X	    if (!strcmp(fname[Function], Argv[i])) break;
X	    }
X	 if (Function == Nfunc) usage();
X	 }
X      else if (!strcmp(Argv[i], "-tile")) {
X	 if ((i+2)> Argc || Argv[i+1][0] == '-') {
X	    while ((Tx+Ty) == 2 ) {
X	       Tx = (int)(Ranf()*8 + 1);
X	       Ty = (int)(Ranf()*8 + 1);
X	       }
X	    }
X	 else {
X	    if(sscanf(Argv[++i], "%dx%d", &Tx, &Ty) != 2) usage();
X	    }
X	 }
X      else if (!strcmp(Argv[i], "-perturb")) {
X	 Pn = pow(10., 1+Ranf()*3); Pv = pow(10.,Ranf()*3);
X	 if      ( (i+2)> Argc || Argv[i+1][0] == '-')       {;}
X	 else if ( sscanf(Argv[++i], "%d,%lf", &Pn, &Pv)==2) {;}
X	 else if (!sscanf(Argv[i],   "%d",     &Pn))         {usage();}
X	 }
X      else if (!strcmp(Argv[i], "-zoom")) {
X	 if (++i>=Argc) usage();
X	 if (!sscanf(Argv[i], "%lf", &Zf) || Zf <= 0) {usage();}
X	 }
X      else if (!strcmp(Argv[i], "-move")) {
X	 if      ( (i+2)> Argc || Argv[i+1][0] == '-')           {usage();}
X	 else if (sscanf(Argv[++i], "%lf,%d", &degr, &dist)==2)  {;}
X	 else if (sscanf(Argv[i], "%3[nsew],%d", dir, &dist)==2) {
X	    for(k=0; k<16; k++) {
X	       if (!strcmp(dir, compass[k])) { degr = k * 22.5; break; }
X	       }
X	    if (k == 16) usage();
X	    }
X	 else usage();
X	 Move = Argv[i];  /* save for output at end to ~/.xmartin */
X	 if (degr < 0 || dist < 0) usage();
X	 degr = 450. - degr;
X	 while (degr > 360) degr -= 360;
X	 }
X      else if (!strcmp(Argv[i], "-display")) {
X	 if (++i>=Argc) usage();
X	 display=Argv[i];
X	 }
X      else if (!strcmp(Argv[i], "-v")) {
X	 fprintf(stderr, "xmartin: version 1.%d\n", PATCHLEVEL);
X	 }
X      else if (!strcmp(Argv[i], "-recall")) {;}
X      else usage();
X      }
X
X   /* open display and extract needed values */
X
X   dpy = XOpenDisplay(display); 
X   if (!dpy) { 
X      fprintf(stderr, "xmartin: Can't open display '%s'.\n", display); 
X      exit(1); 
X      }
X   W = (int) DisplayWidth(dpy,0);
X   H = (int) DisplayHeight(dpy,0);
X   D = (int) DisplayPlanes(dpy,0);
X   if (D > 1) Color++; 
X
X   W /= Tx; H /= Ty;
X   if (W == 0 || H == 0) {
X      fprintf(stderr, "xmartin: tile too small for display\n");
X      exit(1);
X      }
X
X   w_root = DefaultRootWindow(dpy);
X
X   /* search for virtual root (from ssetroot by Tom LaStrange) */
X
X   __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
X   XQueryTree(dpy, w_root, &rootReturn, &parentReturn, &children, &numChildren);
X   for (i = 0; i < numChildren; i++) {
X      Atom actual_type;
X      int actual_format;
X      long nitems, bytesafter;
X      Window *newRoot = NULL;
X
X      if (XGetWindowProperty (dpy, children[i], __SWM_VROOT,0,1,
X          False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter,
X          (unsigned char **) &newRoot) == Success && newRoot) {
X          w_root = *newRoot;
X          break;
X          }
X      }
X
X
X   /* provide default hopalong parameters if needed */ 
X
X   if (Function < 0) {
X      double r = Ranf();
X      if      (r < 0.48) Function = Martin1;
X      else if (r < 0.88) Function = Ejk1;
X      else if (r < 0.98) Function = Ejk2;
X      else               Function = Martin2;
X      }
X   if (!Zf) Zf = (Function == Martin2) ? 4.0 : 1.0;
X   if (A1) {
X      A = Min(A,A1) + Ranf()*(Max(A,A1) - Min(A,A1));
X      if (Af && Ranf()<0.5) A = -A;
X      }
X   if (B1) {
X      B = Min(B,B1) + Ranf()*(Max(B,B1) - Min(B,B1));
X      if (Bf && Ranf()<0.5) B = -B;
X      }
X   if (C1) {
X      C = Min(C,C1) + Ranf()*(Max(C,C1) - Min(C,C1));
X      if (Cf && Ranf()<0.5) C = -C;
X      }
X     
X   if (!mxp && !mxP) {
X      mxp = (int) (0.25 * (float)(W*H));
X      mxP = 3 * mxp;
X      }
X   else if (!mxp) mxp = mxP;
X   else if (!mxP) mxP = 3 * mxp;
X
X   /* allocate resources needed for plot */
X
X   if (!Dynam) {
X      bmn =((W+7)/8)*H*D;
X      bmap = (char *) malloc((unsigned)bmn);
X      if (!bmap) { fprintf(stderr, "xmartin: malloc failed.\n"); exit(1);}
X      bzero(bmap, bmn);
X      xi = XCreateImage
X	      (dpy, DefaultVisual(dpy,0), D, XYPixmap, 0, bmap, W, H, 8, 0);
X      if (!xi) { fprintf(stderr, "xmartin: XCreateImage error.\n"); exit(1); }
X      xi->bitmap_unit = 8; 
X      xi->bitmap_bit_order = LSBFirst;
X      wc = xi->bytes_per_line;
X      }
X   else {
X      gcv.foreground = BlackPixel(dpy, 0);
X      gc = XCreateGC(dpy, w_root, GCForeground, &gcv);
X      pixmap = XCreatePixmap( dpy, w_root, W, H, D);
X      if (!pixmap) {fprintf(stderr, "xmartin: XCreatePixmap error\n"); exit(1);}
X      XFillRectangle(dpy, pixmap, gc, 0, 0, W, H);
X      XSetForeground(dpy, gc, WhitePixel(dpy,0));
X      XSetBackground(dpy, gc, BlackPixel(dpy,0));
X      XSetWindowBackgroundPixmap(dpy, w_root, pixmap);
X      if (!nD) nD = (Tx == 1 && Ty == 1) ? 1024 : 128;
X      xpoints =  (XPoint *)malloc((unsigned)(nD * sizeof(XPoint)));
X      if (!xpoints) { fprintf(stderr, "xmartin: malloc failed.\n"); exit(1);}
X      }
X
X   /* color processing */
X
X   if (Color) {
X      char option[20], *value;
X      XColor used, exact;
X
X      if (!nC) nC = mxP/Ncolors;
X      for(i=0; i<Ncolors; i++) {
X	 sprintf(option, "Color%d", i+1);
X	 value = XGetDefault(dpy, "xmartin", option);
X	 if (!value) value = color_names[i];
X	 if (XAllocNamedColor(dpy, DefaultColormap(dpy,0),value,&used,&exact)) 
X	    colors[i].c_color = (mono) ? WhitePixel(dpy,0) : used.pixel;
X	 else{
X	    colors[i].c_color = WhitePixel(dpy,0);
X	    fprintf(stderr, "xmartin: can't allocate %s (assuming white)\n", 
X		    value);
X	    }
X	 }
X      if (Randomcolor) {
X	 for(i=0; i<Ncolors; i++) colors[i].c_rand =  Ranf();
X	 qsort(colors, Ncolors, sizeof(struct colors), pr_sortcolors);
X	 }
X      if (Dynam)
X	 XSetForeground(dpy, gc, colors[0].c_color);
X      else {
X	 /* XAddPixel(xi, BlackPixel(dpy,0));*/   /* very slow */
X	 if (BlackPixel(dpy,0))
X	    for (i=(D-1)*H*((W+7)/8); i<D*H*((W+7)/8); i++)  bmap[i] = 0377; 
X	 pixel=colors[0].c_color;
X	 color = 0;
X	 }
X      }
X   else if (nC) fprintf(stderr, "xmartin: -nc only used with color displays\n");
X
X   cx = W/2; cy = H/2; mxX = W-1; mxY = H-1;
X   if (dist) { 
X      cx += dist * cos(degr * (pi/180)); 
X      cy -= dist * sin(degr * (pi/180));
X      }
X   x = y = 0;
X
X   fprintf(stderr, "xmartin: %s %s %s",
X      (Dynam) ? "dynamic" : "static", 
X      (Color) ? "color" : "monochrome",
X      fname[Function]);
X   if (Tx!=1 || Ty!=1) fprintf(stderr," (%dx%d tile)", Tx, Ty);
X   if (Pn) fprintf(stderr, " -  Perturbed: every %d points by %.1f", Pn, Pv);
X   fprintf(stderr, "\n");
X   }
X
X
Xusage() { 
X   int f = -1; 
X   fprintf(stderr, "usage: xmartin ");
X   fprintf(stderr, "[-f {%s", fname[++f]);
X   while (++f < Nfunc) 
X      fprintf(stderr, "|%s", fname[f]); 
X   fprintf(stderr, "}] ");
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-a real[[:]:real]] "); 
X   fprintf(stderr, "[-b real[[:]:real]] "); 
X   fprintf(stderr, "[-c real[[:]:real]] "); 
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-p npoints] "); 
X   fprintf(stderr, "[-P npoints] "); 
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-mono]"); 
X   fprintf(stderr, "[-nrc]"); 
X   fprintf(stderr, "[-nc npoints] "); 
X   fprintf(stderr, "[-dynam [nd]]"); 
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-tile [XxY]] "); 
X   fprintf(stderr, "[-perturb [n[,v]]] "); 
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-zoom real] "); 
X   fprintf(stderr, "[-move d,p] "); 
X   fprintf(stderr, "\n       ");
X   fprintf(stderr, "[-recall] "); 
X   fprintf(stderr, "[-display display] "); 
X   fprintf(stderr, "[-v]"); 
X   fprintf(stderr, "\n"); 
X   exit(1); 
X   }
SHAR_EOF
chmod 0644 xmartin.c ||
echo 'restore of xmartin.c failed'
Wc_c="`wc -c < 'xmartin.c'`"
test 18908 -eq "$Wc_c" ||
	echo 'xmartin.c: original size 18908, current size' "$Wc_c"
fi
# ============= xmartin.man ==============
if test -f 'xmartin.man' -a X"$1" != X"-c"; then
	echo 'x - skipping xmartin.man (File already exists)'
else
echo 'x - extracting xmartin.man (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xmartin.man' &&
X.TH xmartin 1 "29 March 1990"
X.SH NAME
Xxmartin \- set X root window to Martin hopalong pattern
X.SH SYNOPSIS
X.B xmartin
X\ [options]
X.br
X.B xmartin+
X[\fB\-q\fP] [\fB\-demo\fP] [\fB\-n \fIname\fR] [\fB\-file\fI file\fR] [options]
X.br
X.SH DESCRIPTION
X.I Xmartin
Xsets the X root window to a \fIhopalong\fP pattern.
X.I Xmartin+
Xis an optional front end.
XThe hopalong algorithm was attributed to Barry Martin of Aston University 
X(Birmingham, England) in  A. K. Dewdney's \fIComputer Recreations\fP column
Xin the September 1986 \fIScientific American\fP.
X.SH OPTIONS
X.TP 5 5
X\fB\-f \fR{ \fBmartin1\fR | \fBmartin2\fR | \fBejk1\fR | \fBejk2\fR }
XRequests a specific hopalong function.
XDefault: randomly selected. The probability that a function will be selected
Xcan be tailored with the \fIxmartin+\fR front end described below.
X.TP 5 5
X.B "\-a  \-b  \-c \fI{ r | r:r | r::r }\fR"
XSets the corresponding hopalong parameter to the real value 
X\fIr\fP or to a random value in the range \fIr:r\fP or \fIr::r\fP. 
XTwo colons indicate
Xa plus-or-minus range. For example, -100:1e3 means a value between -100 and 
X1000, while 1::3 means a value between 1 and 3 or between -1 and -3.
XBy default, random values are assigned. The ranges for default random values
Xcan be tailored with the \fIxmartin+\fP front end described below.
X.TP 5 5
X\fB\-p \fIn \fB\-P \fIn\fR
XSets maximum points to calculate to \fIn\fP. \fB\-p\fP sets the maximum
Xfor in-range (i.e. on display) points. \fB\-P\fP sets the total points
Xto calculate. Defaults: \fB\-p\fP: 25% of pixels in server display (or tile).
X\fB\-P\fP: 3 times the \fB\-p\fP value.
X.TP 5 5
X.B "\-dynam \fI[ nd ]\fR"
XRequests dynamic display. That is, the pattern is displayed as
Xcalculated instead of all at once when complete.
XIf present, \fInd\fP sets the number of in-range points
Xto calculate before displaying them. Default: 1024 (128 if \fB\-tile\fP).
X.TP 5 5
X.B "\-tile \fI[ XxY ]\fR"
XRequests that the root window be tiled with a pattern smaller than the
Xentire display. \fIXxY\fP, if present, requests a specific tiling pattern. 
XFor example, \fB\-tile 3x4\fP requests a tile size of 1/3 the display width and
X1/4 the display height. A random \fIXxY\fR is used if not supplied.
XThis option substantially reduces calculation time and
Xmemory requirements for the pattern.
X.TP 5 5
X.B "\-perturb \fI[ n[,v] ]\fR"
XPerturbs the calculation every \fIn\fP points by offsetting the
Xcurrent x and y values by \fIv\fP. If \fIv\fR or \fIn\fR are not supplied,
Xrandom values are used.
X.TP 5 5
X.B "\-zoom \fIz\fR"
XMultiplies calculation coordinates by \fIz\fP before display. 
XThus, \fIz\fP > 1 magnifies, and \fIz\fP < 1 reduces. Default: 1.0
X(4.0 for \fBmartin2\fP.)
X.TP 5 5
X.B "\-move \fId,p\fR"
XMoves the  pattern \fIp\fR pixels in the direction \fId\fP. 
XThe direction \fId\fP is either a
Xcompass degree heading (0 = north, 90 = east, 180 = south, etc),
Xor the common abbreviations ('n', 'sw', 'nnw', etc.) 
XThus, for example,
X\fB\-move ne,300\fP moves the pattern 300 pixels
Xtoward the upper right corner.
X.TP 5 5
X.B "\-recall"
XRecalls hopalong parameters 
X(\fB\-f\fP, \fB\-a\fP, \fB\-b\fP, \fB\-c\fP, \fB\-zoom\fP, \fB\-move\fP, \fB\-perturb\fP)
Xfrom the last pattern before processing any other 
Xarguments. Thus, for example, \fB\-recall \-zoom 0.5 \-perturb\fP will 
Xzoom out and add random perturbation to the previous pattern. The recall 
Xparameters
Xare saved in \fI$HOME/.xmartin\fP. A pattern generated with \fB\-recall\fP
Xis not itself saved.
X.TP 5 5
X.B "\-nc \fIn\fR"
XFor color or grayscale displays, sets the number of points
Xto calculate before changing colors. (Default: 1/16th of \fB\-P\fP value.)
X.TP 5 5
X.B "\-nrc"
XNon-random color sequence.
X.TP 5 5
X.B "\-mono"
XForces white-on-black for a grayscale (or color) display. You might try this
Xif you don't care for the automatic color-to-grayscale mapping.
X.TP 5 5
X.B "\-v"
XPrints \fIxmartin\fP version and patch level.
X.SH FRONT END
XOn systems with \fIperl\fP installed, the \fIxmartin+\fP front end
Xmay be used to invoke \fIxmartin\fP with probabilities and parameters
Xtailored to your preferences, or to request interesting 
Xparameter sets by name. Tailored parameters and recorded values are stored
Xin \fI$HOME/.xmartin+\fP. 
X\fB\-n \fIname\fR requests a parameter set by name, 
X\fB\-q\fP prints the names in the file,
Xand \fB\-file \fIfile\fR uses a file other than \fI$HOME/.xmartin+\fP.
X\fB\-demo\fP executes (using \fB\-dynam\fP) each entry once.
XAll \fIxmartin\fP 
Xparameters (except \fB\-f\fR or \fB\-recall\fP) are accepted, so you can
Xadd to or alter options generated by \fIxmartin+\fP.
X.PP
XIf you don't have  a \fI.xmartin+\fP
Xfile, one with comments and examples is created.
X.SH RESOURCES
XFor color or grayscale displays, \fIxmartin\fP honors these resources
X(shown with default values):
X.PP
X.B "xmartin*Color1: red"
X.br
X.B "xmartin*Color2: green"
X.br
X.B "xmartin*Color3: blue"
X.br
X.B "xmartin*Color4: yellow"
X.br
X.B "xmartin*Color5: magenta"
X.br
X.B "xmartin*Color6: cyan"
X.br
X.B "xmartin*Color7: coral"
X.br
X.B "xmartin*Color8: slate blue"
X.br
X.B "xmartin*Color9: orange red"
X.br
X.B "xmartin*Color10: spring green"
X.br
X.B "xmartin*Color11: orange"
X.br
X.B "xmartin*Color12: steel blue"
X.br
X.B "xmartin*Color13: pink"
X.br
X.B "xmartin*Color14: violet"
X.br
X.B "xmartin*Color15: firebrick"
X.br
X.B "xmartin*Color16: gold"
X.br
X.PP
XColors are used in this order if \fB\-nrc\fP is selected, otherwise they
Xare used in a random order. Color is changed every \fB\-nc \fIn\fR points
Xduring the calculation.
X.SH BUGS
XOn some systems, certain parameter combinations cause xmartin to abort
Xwith a floating point exception. (The \fIneuron\fP pattern defined by
X\fIxmartin+\fP is an example.) By using \fB\-dynam\fP you can at least see
Xwhat was generated up to the point the calculation exceeded your system's
Xlimits.
X.SH AUTHOR
X.LP
XEd Kubaitis, Computing Services Office, University of Illinois.
SHAR_EOF
chmod 0644 xmartin.man ||
echo 'restore of xmartin.man failed'
Wc_c="`wc -c < 'xmartin.man'`"
test 5884 -eq "$Wc_c" ||
	echo 'xmartin.man: original size 5884, current size' "$Wc_c"
fi
# ============= xmartin.mk ==============
if test -f 'xmartin.mk' -a X"$1" != X"-c"; then
	echo 'x - skipping xmartin.mk (File already exists)'
else
echo 'x - extracting xmartin.mk (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xmartin.mk' &&
XCC = cc  
XCFLAGS = -O
XLIBS = -lm -lX11
XDESTBIN = /usr/local/bin
XDESTMAN = /usr/man/manl
X
Xxmartin: xmartin.c
X	$(CC) $(CFLAGS) -o xmartin xmartin.c $(LIBS)
X
Xinstall: xmartin
X	cp xmartin $(DESTBIN)/xmartin;
X	cp xmartin+.pl $(DESTBIN)/xmartin+;
X	cd $(DESTBIN); chmod 755 xmartin xmartin+
X
Xinstall.man:
X	cp xmartin.man $(DESTMAN)/xmartin.l; chmod 644 $(DESTMAN)/xmartin.l
X      
Xclean:
X	rm -f xmartin core
X
Xuninstall:
X	cd $(DESTBIN); rm -f xmartin xmartin+
X	rm -f $(DESTMAN)/xmartin.l
SHAR_EOF
chmod 0644 xmartin.mk ||
echo 'restore of xmartin.mk failed'
Wc_c="`wc -c < 'xmartin.mk'`"
test 480 -eq "$Wc_c" ||
	echo 'xmartin.mk: original size 480, current size' "$Wc_c"
fi
exit 0

--
Dan Heller
O'Reilly && Associates       Z-Code Software    Comp-sources-x:
Senior Writer                President          comp-sources.x at uunet.uu.net
argv at ora.com                 argv at zipcode.com



More information about the Comp.sources.x mailing list