home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / sources / 2841 < prev    next >
Encoding:
Text File  |  1992-12-22  |  69.5 KB  |  2,178 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!opusc!usceast!patterso
  3. From: patterso@cs.scarolina.edu (Mitchell Patterson)
  4. Subject: xmas -- Christmas tree for X
  5. Message-ID: <patterso.724718909@sycamore.cs.scarolina.edu>
  6. Summary: Christmas display hack
  7. Keywords: xmas X tree Kibo
  8. Sender: usenet@usceast.cs.scarolina.edu (USENET News System)
  9. Organization: USC  Department of Computer Science
  10. Distribution: usa
  11. Date: 18 Dec 92 22:48:29 GMT
  12. Lines: 2164
  13.  
  14. This here's a little X program I've written so I can have a virtual
  15. Christmas. It works with xsaver or standalone. There's an imake plus
  16. a regular Makefile, man pages, the works.
  17.  
  18. MLP
  19.     o / snip snip
  20. -----x--------------------------------------------------------------
  21.     o \
  22. #! /bin/sh
  23. # This is a shell archive, meaning:
  24. # 1. Remove everything above the #! /bin/sh line.
  25. # 2. Save the resulting text in a file.
  26. # 3. Execute the file with /bin/sh (not csh) to create the files:
  27. #    README
  28. #    Imakefile
  29. #    Makefile.noimake
  30. #    screenhack.h
  31. #    vroot.h
  32. #    xmas.h
  33. #    screenhack.c
  34. #    resources.c
  35. #    usleep.c
  36. #    xmas.c
  37. #    pt_in_tri.c
  38. #    candy.c
  39. #    gift.c
  40. #    snow.c
  41. #    ornament.c
  42. #    color.c
  43. #    xmas.man
  44. # This archive created: Fri Dec 18 17:43:40 1992
  45. export PATH; PATH=/bin:$PATH
  46. echo shar: extracting "'README'" '(2913 characters)'
  47. if test -f 'README'
  48. then
  49.     echo shar: will not over-write existing file "'README'"
  50. else
  51. sed 's/^    X//' << \SHAR_EOF > 'README'
  52.     XHowdy.
  53.     X
  54.     XAnd so this is xmas, an X display hack that draws a Christmas tree on the
  55.     Xroot window or in a window of its own. 
  56.     X
  57.     XIf you're using a Sun, how 'bout take a look at the note on SunOS's
  58.     XXmu library. It's at the bottom of this file in the Notes section.
  59.     X
  60.     XHow To Build It:
  61.     X----------------
  62.     XIf you have imake, type
  63.     X   xmkmf
  64.     X   make
  65.     Xand that should do it. (Chyeah, right, Garth.)
  66.     X
  67.     XIf you don't have imake, edit Makefile.noimake to change whatever config
  68.     Xstuff is necessary and then type
  69.     X   make -f Makefile.noimake
  70.     Xand that should do it.
  71.     X
  72.     XInstallation:
  73.     X-------------
  74.     XIf you have imake, type
  75.     X   make man
  76.     X   make install BINDIR="<wherever xmas should go>"
  77.     X   make install.man MANDIR="<wherever the man page should go>"
  78.     X
  79.     XIf you don't have imake, type
  80.     X   make -f Makefile.noimake man 
  81.     X   make -f Makefile.noimake install\
  82.     X      BINDIR="wherever xmas should go" MANDIR="wherever manpage goes"
  83.     X
  84.     XFor example, if you wanted xmas to go /usr/local/xmas and its man page to
  85.     Xgo to /usr/local/man/man1, you'd type
  86.     X   make install BINDIR="/usr/local/xmas" MANDIR="/usr/local/man/man1"
  87.     X
  88.     XRunning Xmas:
  89.     X-------------
  90.     XIf you don't want to RTM, and I don't blame you, type 
  91.     X   xmas -help
  92.     Xfor a usage message that explains the options and gives you an
  93.     Xexample invocation of the program. You'll also see the message if you
  94.     Xgive an invalid option. In that case, xmas also whines about the bad 
  95.     Xoption(s).
  96.     X
  97.     XNotes:
  98.     X------
  99.     X* Type "make -f Makefile.noimake doc" for a man page with all the nroff
  100.     X  control stuff removed.
  101.     X
  102.     X* This thing has been tested on Sun SPARC2's, DECstations, IBM RS/6000's,
  103.     X  and NCD monochrome X terminals. It seems to work on all of them. I've
  104.     X  tried SunOS cc, AIX cc, and gcc on the Sun.
  105.     X
  106.     X* The code is kind of ugly, but I wanted to post it before Christmas. The
  107.     X  next version will be cleaner.
  108.     X
  109.     X* xmas works just fine with xscreensaver. That's a cool program to get,
  110.     X  if you don't already have it. And if you want to write little display
  111.     X  hacks like this one, you can't beat screenhack, which comes with
  112.     X  xscreensaver. It's at export.lcs.mit.edu, I think.
  113.     X
  114.     X* If you use imake on a Sun, and you get the following error message from
  115.     X  the loader:
  116.     X     "ld: Undefined symbol
  117.     X        _get_wmShellWidgetClass
  118.     X        _get_applicationShellWidgetClass,"
  119.     X  you have two choices. One is to ignore the message; xmas works fine
  120.     X  even if make says it failed. The other is to edit the Makefile produced
  121.     X  by imake. Find the line that says "EXTRA_LIBRARIES" and change it from
  122.     X     EXTRA_LIBRARIES = -lXmu -lXext -lXt -lX11 -lm
  123.     X  to
  124.     X     EXTRA_LIBRARIES = -Bstatic -lXmu -Bdynamic -lXext -lXt -lX11 -lm
  125.     X  There's a problem with the Xmu library as a shared object on Suns; 
  126.     X  the -B's tell SunOS ld to link with the static Xmu library and use
  127.     X  the default shared libraries for everything else. Makefile.noimake
  128.     X  takes care of this problem for you.
  129.     X
  130.     XMerry Christmas, everybody.
  131.     X
  132.     XMitch Patterson
  133.     Xmpatters@cs.scarolina.edu
  134. SHAR_EOF
  135. if test 2913 -ne "`wc -c < 'README'`"
  136. then
  137.     echo shar: error transmitting "'README'" '(should have been 2913 characters)'
  138. fi
  139. fi # end of overwriting check
  140. echo shar: extracting "'Imakefile'" '(335 characters)'
  141. if test -f 'Imakefile'
  142. then
  143.     echo shar: will not over-write existing file "'Imakefile'"
  144. else
  145. sed 's/^    X//' << \SHAR_EOF > 'Imakefile'
  146.     X#
  147.     X# Imakefile for xmas. Don't ask me what any of this stuff does.
  148.     X#
  149.     XEXTRA_LIBRARIES = -lXmu -lXext -lXt -lX11 -lm
  150.     XSRCS = screenhack.c\
  151.     X       resources.c\
  152.     X       usleep.c\
  153.     X       xmas.c\
  154.     X       pt_in_tri.c\
  155.     X       candy.c\
  156.     X       gift.c\
  157.     X       color.c\
  158.     X       snow.c\
  159.     X       ornament.c
  160.     XOBJS = $(SRCS:.c=.o)
  161.     XComplexProgramTarget(xmas)
  162. SHAR_EOF
  163. if test 335 -ne "`wc -c < 'Imakefile'`"
  164. then
  165.     echo shar: error transmitting "'Imakefile'" '(should have been 335 characters)'
  166. fi
  167. fi # end of overwriting check
  168. echo shar: extracting "'Makefile.noimake'" '(3473 characters)'
  169. if test -f 'Makefile.noimake'
  170. then
  171.     echo shar: will not over-write existing file "'Makefile.noimake'"
  172. else
  173. sed 's/^    X//' << \SHAR_EOF > 'Makefile.noimake'
  174.     X# If you don't have imake, this should do the trick.
  175.     X#
  176.     X# Makefile for xmas and every other X program I write. Only the
  177.     X# names change.
  178.     X#
  179.     X# Type "make" to make the program.
  180.     X# Type "make install" to put it where it needs to go.
  181.     X# Type "make doc" to create a text-only man page.
  182.     X# Type "make man" to create an nroff-formatted man page.
  183.     X# Type "make clean" to remove the executable, the object files, and any
  184.     X# core dump that might be laying around.
  185.     X#
  186.     X#---------------------------------------------------------------------------
  187.     X# Configuration stuff:
  188.     X#---------------------------------------------------------------------------
  189.     X#
  190.     X# Where this thing should go.
  191.     X#
  192.     XBINDIR = /usr/local/xmas
  193.     X#
  194.     X# Where man pages should go.
  195.     X#
  196.     XMANDIR = /usr/local/xmas
  197.     X#
  198.     X# Where the include files live, if they're someplace weird.
  199.     X#
  200.     XINCL =
  201.     X#
  202.     X# Where the libraries live, if they aren't in the usual places. On
  203.     X# Suns you'll probably want to leave the directive for /usr/lib/X11;
  204.     X# that way you don't have to worry about defining LD_LIBRARY_PATH in
  205.     X# your environment.
  206.     X#
  207.     XLIBDIRS = -L/usr/local/lib -L/usr/lib/X11
  208.     X#
  209.     X# Preprocessor and compiler flags. On Ultrix machines, use the CFLAGS
  210.     X# definition that incorporates CPPFLAGS.
  211.     X# The _NO_PROTO is for non-ANSI compilers, like SunOS cc.
  212.     X#
  213.     XCPPFLAGS = $(INCL) -D_NO_PROTO
  214.     X#CPPFLAGS = $(INCL)
  215.     XCFLAGS = -g
  216.     X#CFLAGS = -g $(CPPFLAGS)
  217.     X#
  218.     X# Which libraries to use and where they live. If you're not on a Sun,
  219.     X# the second definition should work just fine.
  220.     X#
  221.     X# SunOS Xmu is screwed, so I link it statically.
  222.     X#
  223.     XLIBS = $(LIBDIRS) -Bstatic -lXmu -Bdynamic -lXext -lXt -lX11 -lm
  224.     X#LIBS = $(LIBDIRS) -lXmu -lXext -lXt -lX11 -lm
  225.     X#
  226.     X# Flags to the loader. You probably won't have to mess with this one.
  227.     X#
  228.     XLDFLAGS = $(LIBS)
  229.     X#
  230.     X#---------------------------------------------------------------------------
  231.     X# Nothing below this point should have to change.
  232.     X#---------------------------------------------------------------------------
  233.     X#
  234.     X# Our application & its constituents.
  235.     X#
  236.     XAPP     = xmas
  237.     XOBJS    = screenhack.o\
  238.     X          resources.o\
  239.     X          usleep.o\
  240.     X          xmas.o\
  241.     X          pt_in_tri.o\
  242.     X          candy.o\
  243.     X          gift.o\
  244.     X          snow.o\
  245.     X          ornament.o\
  246.     X          color.o
  247.     XHEADERS = screenhack.h\
  248.     X          vroot.h\
  249.     X          xmas.h
  250.     XDOCSRC  = xmas.man
  251.     XDOCTXT  = xmas.doc
  252.     XMANPAGE = xmas.1
  253.     X#
  254.     X# Application target.
  255.     X#
  256.     Xcompile:
  257.     X    -mv Makefile Makefile.bak
  258.     X    cp Makefile.noimake Makefile
  259.     X    make $(APP)
  260.     X
  261.     X$(APP): $(OBJS)
  262.     X    $(CC) -o $@ $(OBJS) $(LDFLAGS)
  263.     X
  264.     X$(OBJS): $(HEADERS)
  265.     X#
  266.     X# Installation
  267.     X#
  268.     Xinstall: $(APP) $(MANPAGE)
  269.     X    cp $(APP) $(BINDIR)
  270.     X    chmod 755 $(BINDIR)/$(APP)
  271.     X    cp $(MANPAGE) $(MANDIR)
  272.     X#
  273.     X# Archive this baby.
  274.     X#
  275.     Xshar:
  276.     X    shar -a README Imakefile Makefile.noimake\
  277.     X            $(HEADERS) $(OBJS:.o=.c)\
  278.     X            $(DOCSRC) > xmas.shar
  279.     X#
  280.     X# Make docs.
  281.     X#
  282.     X$(DOCTXT) doc: $(DOCSRC)
  283.     X    nroff -man < $(DOCSRC) | sed 's/.//g' > $(DOCTXT)
  284.     X#
  285.     X# Make man page
  286.     X#
  287.     X$(MANPAGE) man: $(DOCSRC)
  288.     X    nroff -man < $(DOCSRC) > $(MANPAGE)
  289.     X#
  290.     X# Cleanup target.
  291.     X#
  292.     Xclean:
  293.     X    rm -f $(APP) $(OBJS) $(DOCTXT) $(MANPAGE) Makefile Makefile.bak core
  294.     X#
  295.     X# The Anal-Retentive Parser
  296.     X#
  297.     Xlint:
  298.     X    @for i in $(OBJS:.o=.c);\
  299.     X    do\
  300.     X        echo "*** Linting $$i ***" ;\
  301.     X        $(LINT) $(CPPFLAGS) $$i;\
  302.     X    done
  303.     X#
  304.     X# backups
  305.     X#
  306.     Xback bak backups:
  307.     X    @if [ ! -d BACKUPS ];\
  308.     X    then\
  309.     X        echo "ERROR: No directory named BACKUPS.";\
  310.     X    elif [ ! -w BACKUPS ];\
  311.     X    then\
  312.     X        echo "ERROR: BACKUPS is not writeable";\
  313.     X    else\
  314.     X        make real-backups;\
  315.     X    fi
  316.     X
  317.     Xreal-backups:
  318.     X    -cp $(OBJS:.o=.c) $(HEADERS) $(DOCSRC)\
  319.     X        README Imakefile Makefile.noimake\
  320.     X     BACKUPS
  321. SHAR_EOF
  322. echo shar: 1 control character may be missing from "'Makefile.noimake'"
  323. if test 3473 -ne "`wc -c < 'Makefile.noimake'`"
  324. then
  325.     echo shar: error transmitting "'Makefile.noimake'" '(should have been 3473 characters)'
  326. fi
  327. fi # end of overwriting check
  328. echo shar: extracting "'screenhack.h'" '(1182 characters)'
  329. if test -f 'screenhack.h'
  330. then
  331.     echo shar: will not over-write existing file "'screenhack.h'"
  332. else
  333. sed 's/^    X//' << \SHAR_EOF > 'screenhack.h'
  334.     X#ifndef _SCREENHACK_H_
  335.     X#define _SCREENHACK_H_
  336.     X
  337.     X#include <X11/Xlib.h>
  338.     X#include <X11/Xresource.h>
  339.     X#include <X11/Xos.h>
  340.     X#include "vroot.h"
  341.     X
  342.     Xextern Bool mono_p;
  343.     Xextern char *progname;
  344.     Xextern char *progclass;
  345.     Xextern XrmDatabase db;
  346.     Xextern XrmOptionDescRec options [];
  347.     Xextern int options_size;
  348.     Xextern char *defaults [];
  349.     X
  350.     X#if __STDC__
  351.     X# define P(x)x
  352.     X#else
  353.     X# define P(x)()
  354.     X#endif
  355.     X
  356.     Xextern void screenhack P((Display*,Window));
  357.     X
  358.     X#define usleep screenhack_usleep
  359.     X
  360.     Xextern void screenhack_usleep P((unsigned long));
  361.     Xextern char *get_string_resource P((char*,char*));
  362.     Xextern Bool get_boolean_resource P((char*,char*));
  363.     Xextern int get_integer_resource P((char*,char*));
  364.     Xextern unsigned int get_pixel_resource P((char*,char*,Display*,Colormap));
  365.     X
  366.     Xvoid hsv_to_rgb P((int,double,double,unsigned short*,
  367.     X           unsigned short*,unsigned short*));
  368.     Xvoid rgb_to_hsv P((unsigned short,unsigned short,unsigned short,
  369.     X           int*,double*,double*));
  370.     Xvoid cycle_hue P((XColor*,int));
  371.     X
  372.     Xstatic double _frand_tmp_;
  373.     X#define frand(f)                        \
  374.     X (_frand_tmp_ = (((double) random()) /                 \
  375.     X         (((unsigned int)~0) / ((double) (f+f)))),    \
  376.     X  _frand_tmp_ < 0 ? -_frand_tmp_ : _frand_tmp_)
  377.     X
  378.     X#undef P
  379.     X#endif /* _SCREENHACK_H_ */
  380. SHAR_EOF
  381. if test 1182 -ne "`wc -c < 'screenhack.h'`"
  382. then
  383.     echo shar: error transmitting "'screenhack.h'" '(should have been 1182 characters)'
  384. fi
  385. fi # end of overwriting check
  386. echo shar: extracting "'vroot.h'" '(5068 characters)'
  387. if test -f 'vroot.h'
  388. then
  389.     echo shar: will not over-write existing file "'vroot.h'"
  390. else
  391. sed 's/^    X//' << \SHAR_EOF > 'vroot.h'
  392.     X/*****************************************************************************/
  393.     X/**                   Copyright 1991 by Andreas Stolcke                     **/
  394.     X/**               Copyright 1990 by Solbourne Computer Inc.                 **/
  395.     X/**                          Longmont, Colorado                             **/
  396.     X/**                                                                         **/
  397.     X/**                           All Rights Reserved                           **/
  398.     X/**                                                                         **/
  399.     X/**    Permission to use, copy, modify, and distribute this software and    **/
  400.     X/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
  401.     X/**    granted, provided that the above copyright notice appear  in  all    **/
  402.     X/**    copies and that both  that  copyright  notice  and  this  permis-    **/
  403.     X/**    sion  notice appear in supporting  documentation,  and  that  the    **/
  404.     X/**    name of Solbourne not be used in advertising                         **/
  405.     X/**    in publicity pertaining to distribution of the  software  without    **/
  406.     X/**    specific, written prior permission.                                  **/
  407.     X/**                                                                         **/
  408.     X/**    ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/
  409.     X/**    WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF    **/
  410.     X/**    MERCHANTABILITY  AND  FITNESS,  IN  NO  EVENT SHALL ANDREAS STOLCKE  **/
  411.     X/**    OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL    **/
  412.     X/**    DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA   **/
  413.     X/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
  414.     X/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
  415.     X/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
  416.     X/*****************************************************************************/
  417.     X/*
  418.     X * vroot.h -- Virtual Root Window handling header file
  419.     X *
  420.     X * This header file redefines the X11 macros RootWindow and DefaultRootWindow,
  421.     X * making them look for a virtual root window as provided by certain `virtual'
  422.     X * window managers like swm and tvtwm. If none is found, the ordinary root
  423.     X * window is returned, thus retaining backward compatibility with standard
  424.     X * window managers.
  425.     X * The function implementing the virtual root lookup remembers the result of
  426.     X * its last invocation to avoid overhead in the case of repeated calls
  427.     X * on the same display and screen arguments. 
  428.     X * The lookup code itself is taken from Tom LaStrange's ssetroot program.
  429.     X *
  430.     X * Most simple root window changing X programs can be converted to using
  431.     X * virtual roots by just including
  432.     X *
  433.     X * #include <X11/vroot.h>
  434.     X *
  435.     X * after all the X11 header files.  It has been tested on such popular
  436.     X * X clients as xphoon, xfroot, xloadimage, and xaqua.
  437.     X * It also works with the core clients xprop, xwininfo, xwd, and editres
  438.     X * (and is necessary to get those clients working under tvtwm).
  439.     X * It does NOT work with xsetroot; get the xsetroot replacement included in
  440.     X * the tvtwm distribution instead.
  441.     X *
  442.     X * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
  443.     X * - replaced all NULL's with properly cast 0's, 5/6/91
  444.     X * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
  445.     X * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
  446.     X */
  447.     X
  448.     X#ifndef _VROOT_H_
  449.     X#define _VROOT_H_
  450.     X
  451.     X#if !defined(lint) && !defined(SABER)
  452.     Xstatic char vroot_rcsid[] = "$Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke $";
  453.     X#endif
  454.     X
  455.     X#include <X11/X.h>
  456.     X#include <X11/Xatom.h>
  457.     X#include <X11/Xlib.h>
  458.     X
  459.     Xstatic Window
  460.     XVirtualRootWindowOfScreen(screen)
  461.     X    Screen *screen;
  462.     X{
  463.     X    static Screen *save_screen = (Screen *)0;
  464.     X    static Window root = (Window)0;
  465.     X
  466.     X    if (screen != save_screen) {
  467.     X        Display *dpy = DisplayOfScreen(screen);
  468.     X        Atom __SWM_VROOT = None;
  469.     X        int i;
  470.     X        Window rootReturn, parentReturn, *children;
  471.     X        unsigned int numChildren;
  472.     X
  473.     X        root = RootWindowOfScreen(screen);
  474.     X
  475.     X        /* go look for a virtual root */
  476.     X        __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  477.     X        if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
  478.     X                 &children, &numChildren)) {
  479.     X            for (i = 0; i < numChildren; i++) {
  480.     X                Atom actual_type;
  481.     X                int actual_format;
  482.     X                unsigned long nitems, bytesafter;
  483.     X                Window *newRoot = (Window *)0;
  484.     X
  485.     X                if (XGetWindowProperty(dpy, children[i],
  486.     X                    __SWM_VROOT, 0, 1, False, XA_WINDOW,
  487.     X                    &actual_type, &actual_format,
  488.     X                    &nitems, &bytesafter,
  489.     X                    (unsigned char **) &newRoot) == Success
  490.     X                    && newRoot) {
  491.     X                    root = *newRoot;
  492.     X                    break;
  493.     X                }
  494.     X            }
  495.     X            if (children)
  496.     X                XFree((char *)children);
  497.     X        }
  498.     X
  499.     X        save_screen = screen;
  500.     X    }
  501.     X
  502.     X    return root;
  503.     X}
  504.     X
  505.     X#undef RootWindowOfScreen
  506.     X#define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
  507.     X
  508.     X#undef RootWindow
  509.     X#define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
  510.     X
  511.     X#undef DefaultRootWindow
  512.     X#define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
  513.     X
  514.     X#endif /* _VROOT_H_ */
  515. SHAR_EOF
  516. if test 5068 -ne "`wc -c < 'vroot.h'`"
  517. then
  518.     echo shar: error transmitting "'vroot.h'" '(should have been 5068 characters)'
  519. fi
  520. fi # end of overwriting check
  521. echo shar: extracting "'xmas.h'" '(3993 characters)'
  522. if test -f 'xmas.h'
  523. then
  524.     echo shar: will not over-write existing file "'xmas.h'"
  525. else
  526. sed 's/^    X//' << \SHAR_EOF > 'xmas.h'
  527.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  528.     X**
  529.     X** Permission to use, copy, modify, distribute, and sell this software and its
  530.     X** documentation for any purpose is hereby granted without fee, provided that
  531.     X** the above copyright notice appear in all copies and that both that
  532.     X** copyright notice and this permission notice appear in supporting
  533.     X** documentation.  No representations are made about the suitability of this
  534.     X** software for any purpose.  It is provided "as is" without express or 
  535.     X** implied warranty.
  536.     X**/
  537.     X
  538.     X/*
  539.     X** Which release are we?
  540.     X*/
  541.     X#define RELEASE "1.6"
  542.     X
  543.     X/*
  544.     X** Convert degrees to radians for the C trig functions.
  545.     X*/
  546.     X#define DEG2RAD(x) ((x) * M_PI / 180.0)
  547.     X
  548.     X/*
  549.     X** XDrawArc() divides a degree into 64 clicks. This draws a half-circle,
  550.     X** which is what I use for the top of a candycane.
  551.     X*/
  552.     X#define HALF_CIRCLE (180 * 64)
  553.     X
  554.     X/*
  555.     X** We have 400 lights.
  556.     X*/
  557.     X#define NUM_LIGHTS 400
  558.     X
  559.     X/*
  560.     X** Size of our lights. 1-dot lights are a little too small.
  561.     X*/
  562.     X#define LIGHT_HEIGHT 2
  563.     X#define LIGHT_WIDTH  2
  564.     X
  565.     X/*
  566.     X** This is the length of the arms of the star at the top of the tree.
  567.     X*/
  568.     X#define STAR_ARM_LENGTH 5
  569.     X
  570.     X/*
  571.     X** Percentage of the window that serves as the top and bottom margin.
  572.     X*/
  573.     X#define MARGIN 10
  574.     X
  575.     X/*
  576.     X** Default values for the usage message.
  577.     X*/
  578.     X#define DEF_BG              "black"      /* default background color */
  579.     X#define DEF_STARCOLOR      "yellow"      /* default star color */
  580.     X#define DEF_STARBLINKS     "it doesn't"  /* used in usage message */
  581.     X#define DEF_DELAY          1500          /* default cycle time */
  582.     X#define DEF_SEED           131           /* default seed for randoms */
  583.     X#define DEF_GIFTLABEL      "no gift"     /* used in usage message */
  584.     X#define DEF_GIFTCOLOR      "blue"        /* default color of gift */
  585.     X#define DEF_GIFTLABELCOLOR "white"       /* default color for tag text */
  586.     X#define DEF_NUM_CANDYCANES 0             /* default number of candy canes */
  587.     X#define DEF_CANDY_LENGTH   30            /* length of candy cane */
  588.     X#define DEF_CANDY_WIDTH    10            /* width of candy cane */
  589.     X#define DEF_CANDY_HEIGHT   10            /* height of candy cane */
  590.     X#define DEF_SNOW           "no snow"     /* used in usage message */
  591.     X#define NUM_SNOWFLAKES     1000          /* number of snowflakes */
  592.     X#define DEF_NUM_ORNAMENTS  0             /* default number of ornaments */    
  593.     X#define DEF_BACKING_STORE  "True"        /* default flag for backing store */
  594.     X
  595.     X/*
  596.     X** Macros for access into the color table.
  597.     X*/
  598.     X#define BACKGROUND 0
  599.     X#define STARCOLOR  1
  600.     X#define BOXCOLOR   2
  601.     X#define TEXTCOLOR  3
  602.     X#define WHITE      4
  603.     X#define RED        (WHITE + 1)
  604.     X#define GREEN      (WHITE + 2)
  605.     X#define ORANGE     (WHITE + 3)
  606.     X#define YELLOW     (WHITE + 4)
  607.     X
  608.     X#define NUM_COLORS 9
  609.     X
  610.     X/*
  611.     X** We want to exclude a few of the colors from the choices for 
  612.     X** Christmas lights; these make the exclusion changeproof.
  613.     X*/
  614.     X#define FIRST_LIGHT WHITE            /* lowest valid light color */
  615.     X#define LAST_LIGHT  YELLOW           /* highest valid light color */
  616.     X
  617.     X/*
  618.     X** How far does snow travel in a single fall cycle?
  619.     X*/
  620.     X#define MAX_SNOWFALL_RATE 100
  621.     X
  622.     X/*
  623.     X** Time in microseconds for a single snowfall cycle. 
  624.     X*/
  625.     X#define SNOWFALL_TIME 200000
  626.     X
  627.     X/*
  628.     X** Snow starts above the window.
  629.     X*/
  630.     X#define SNOW_START (-1)
  631.     X
  632.     X/*
  633.     X** It takes too long to make all the snowflakes fall every cycle, so
  634.     X** now flakes have a 1 in 5 chance of dropping.
  635.     X*/
  636.     X#define SNOWFLAKES_CHANCE 5
  637.     X
  638.     X/*
  639.     X** I let snowdrifts get higher if a column is within this tolerance of the
  640.     X** height of its neighbors.
  641.     X*/
  642.     X#define SNOWFALL_TOLERANCE 2
  643.     X
  644.     X/*
  645.     X** The bitmaps I use for ornaments are 16 by 16.
  646.     X*/
  647.     X#define BITMAP_WIDTH 16
  648.     X#define BITMAP_HEIGHT 16
  649.     X
  650.     X/*
  651.     X** SunOS doesn't have a header for these.
  652.     X*/
  653.     Xvoid   srand48();
  654.     Xlong   lrand48();
  655.     Xdouble drand48();
  656.     X
  657.     X/*
  658.     X** Functions defined in the xmas code.
  659.     X*/
  660.     Xvoid          pt_in_triangle();
  661.     Xvoid          draw_candy();
  662.     Xvoid          draw_gift();
  663.     Xvoid          snow_init();
  664.     Xvoid          draw_snow();
  665.     Xvoid          draw_ornaments();
  666.     Xvoid          color_init();
  667.     Xunsigned long get_color();
  668. SHAR_EOF
  669. if test 3993 -ne "`wc -c < 'xmas.h'`"
  670. then
  671.     echo shar: error transmitting "'xmas.h'" '(should have been 3993 characters)'
  672. fi
  673. fi # end of overwriting check
  674. echo shar: extracting "'screenhack.c'" '(4496 characters)'
  675. if test -f 'screenhack.c'
  676. then
  677.     echo shar: will not over-write existing file "'screenhack.c'"
  678. else
  679. sed 's/^    X//' << \SHAR_EOF > 'screenhack.c'
  680.     X/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@lucid.com>
  681.     X *
  682.     X * Permission to use, copy, modify, distribute, and sell this software and its
  683.     X * documentation for any purpose is hereby granted without fee, provided that
  684.     X * the above copyright notice appear in all copies and that both that
  685.     X * copyright notice and this permission notice appear in supporting
  686.     X * documentation.  No representations are made about the suitability of this
  687.     X * software for any purpose.  It is provided "as is" without express or 
  688.     X * implied warranty.
  689.     X */
  690.     X
  691.     X/* This file contains simple code to open a window or draw on the root.
  692.     X   The idea being that, when writing a graphics hack, you can just link
  693.     X   with this .o to get all of the uninteresting junk out of the way.
  694.     X
  695.     X   -  create a procedure `screenhack(dpy, window)'
  696.     X
  697.     X   -  create a variable `char *progclass' which names this program's
  698.     X      resource class.
  699.     X
  700.     X   -  create a variable `char defaults []' for the default resources.
  701.     X
  702.     X   -  create a variable `XrmOptionDescRec options []' for the command-line,
  703.     X      and `int options_size' which is `XtNumber (options)'.
  704.     X
  705.     X   And that's it...
  706.     X */
  707.     X
  708.     X#include <stdio.h>
  709.     X#include <X11/Intrinsic.h>
  710.     X#include <X11/Xmu/Error.h>
  711.     X#include "screenhack.h"
  712.     X
  713.     Xchar *progname;
  714.     Xchar *progclass;
  715.     XXrmDatabase db;
  716.     XBool mono_p;
  717.     X
  718.     X
  719.     Xstatic XrmOptionDescRec default_options [] = {
  720.     X  { "-root",    ".root",        XrmoptionNoArg, "True" },
  721.     X  { "-window",    ".root",        XrmoptionNoArg, "False" },
  722.     X  { "-mono",    ".mono",        XrmoptionNoArg, "True" },
  723.     X  { "-install",    ".installColormap",    XrmoptionNoArg, "True" }
  724.     X};
  725.     X
  726.     Xstatic char *default_defaults[] = {
  727.     X  "*root:        false",
  728.     X  "*geometry:        500x500", /* this should be .geometry, but nooooo... */
  729.     X  "*mono:        false",
  730.     X  "*installColormap:    false",
  731.     X  0
  732.     X};
  733.     X
  734.     Xstatic XrmOptionDescRec *merged_options;
  735.     Xstatic int merged_options_size;
  736.     Xstatic char **merged_defaults;
  737.     X
  738.     Xstatic void
  739.     Xmerge_options ()
  740.     X{
  741.     X  int options_sizeof = options_size * sizeof (options[0]);
  742.     X  int defaults_size;
  743.     X  merged_options_size = XtNumber (default_options) + options_size;
  744.     X  merged_options = (XrmOptionDescRec *)
  745.     X    malloc (sizeof (default_options) + options_sizeof);
  746.     X  bcopy (options, merged_options, options_sizeof);
  747.     X  bcopy (default_options, merged_options + options_size,
  748.     X     sizeof (default_options));
  749.     X
  750.     X  for (defaults_size = 0; defaults [defaults_size]; defaults_size++);
  751.     X  merged_defaults = (char **)
  752.     X    malloc (sizeof (default_defaults) + (defaults_size * sizeof (char *)));
  753.     X  bcopy (default_defaults, merged_defaults, sizeof (default_defaults));
  754.     X  bcopy (defaults, merged_defaults - 1 +
  755.     X     (sizeof (default_defaults) / sizeof (default_defaults[0])),
  756.     X     ((defaults_size + 1) * sizeof (defaults[0])));
  757.     X}
  758.     X
  759.     X
  760.     X/* Make the X errors print out the name of this program, so we have some
  761.     X   clue which one has a bug when they die under the screensaver.
  762.     X */
  763.     X
  764.     Xstatic int
  765.     Xscreenhack_ehandler (dpy, error)
  766.     X     Display *dpy;
  767.     X     XErrorEvent *error;
  768.     X{
  769.     X  fprintf (stderr, "\nX error in %s:\n", progname);
  770.     X  if (XmuPrintDefaultErrorMessage (dpy, error, stderr))
  771.     X    exit (-1);
  772.     X  else
  773.     X    fprintf (stderr, " (nonfatal.)\n");
  774.     X  return 0;
  775.     X}
  776.     X
  777.     X
  778.     Xmain (argc, argv)
  779.     X     int argc;
  780.     X     char **argv;
  781.     X{
  782.     X  XtAppContext app;
  783.     X  Widget toplevel;
  784.     X  Display *dpy;
  785.     X  Window window;
  786.     X  Colormap cmap;
  787.     X
  788.     X  merge_options ();
  789.     X  toplevel = XtAppInitialize (&app, progclass, merged_options,
  790.     X                  merged_options_size, &argc, argv,
  791.     X                  merged_defaults, 0, 0);
  792.     X  dpy = XtDisplay (toplevel);
  793.     X  db = XtDatabase (dpy);
  794.     X  XtGetApplicationNameAndClass (dpy, &progname, &progclass);
  795.     X  XSetErrorHandler (screenhack_ehandler);
  796.     X
  797.     Xif ( argc > 1 )
  798.     X    {
  799.     X    usage(argc, argv);
  800.     X    exit (1);
  801.     X    }
  802.     X
  803.     X  cmap = DefaultColormap (dpy, DefaultScreen (dpy));
  804.     X  mono_p = get_boolean_resource ("mono", "Boolean");
  805.     X  if (CellsOfScreen (DefaultScreenOfDisplay (dpy)) <= 2)
  806.     X    mono_p = True;
  807.     X  if (get_boolean_resource ("root", "Boolean"))
  808.     X    {
  809.     X      window = RootWindowOfScreen (XtScreen (toplevel));
  810.     X      XtDestroyWidget (toplevel);
  811.     X    }
  812.     X  else
  813.     X    {
  814.     X      XtRealizeWidget (toplevel);
  815.     X      window = XtWindow (toplevel);
  816.     X      if (get_boolean_resource ("installColormap", "InstallColormap"))
  817.     X    {
  818.     X      cmap = XCreateColormap (dpy, window,
  819.     X                  DefaultVisualOfScreen (XtScreen (toplevel)),
  820.     X                  AllocNone);
  821.     X      XSetWindowColormap (dpy, window, cmap);
  822.     X    }
  823.     X    }
  824.     X  XSetWindowBackground (dpy, window,
  825.     X            get_pixel_resource ("background", "Background",
  826.     X                        dpy, cmap));
  827.     X  XClearWindow (dpy, window);
  828.     X/*
  829.     X  XSync (dpy, False);
  830.     X*/
  831.     X    XFlush(dpy);
  832.     X  srandom ((int) time ((time_t *) 0));
  833.     X  screenhack (dpy, window);
  834.     X}
  835. SHAR_EOF
  836. if test 4496 -ne "`wc -c < 'screenhack.c'`"
  837. then
  838.     echo shar: error transmitting "'screenhack.c'" '(should have been 4496 characters)'
  839. fi
  840. fi # end of overwriting check
  841. echo shar: extracting "'resources.c'" '(3123 characters)'
  842. if test -f 'resources.c'
  843. then
  844.     echo shar: will not over-write existing file "'resources.c'"
  845. else
  846. sed 's/^    X//' << \SHAR_EOF > 'resources.c'
  847.     X/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@lucid.com>
  848.     X *
  849.     X * Permission to use, copy, modify, distribute, and sell this software and its
  850.     X * documentation for any purpose is hereby granted without fee, provided that
  851.     X * the above copyright notice appear in all copies and that both that
  852.     X * copyright notice and this permission notice appear in supporting
  853.     X * documentation.  No representations are made about the suitability of this
  854.     X * software for any purpose.  It is provided "as is" without express or 
  855.     X * implied warranty.
  856.     X */
  857.     X
  858.     X#include <X11/Xlib.h>
  859.     X#include <X11/Xresource.h>
  860.     X#include <stdio.h>
  861.     X
  862.     X/* Resource functions.  Assumes: */
  863.     X
  864.     Xextern char *progname;
  865.     Xextern char *progclass;
  866.     Xextern XrmDatabase db;
  867.     X
  868.     X#ifndef isupper
  869.     X# define isupper(c)  ((c) >= 'A' && (c) <= 'Z')
  870.     X#endif
  871.     X#ifndef _tolower
  872.     X# define _tolower(c)  ((c) - 'A' + 'a')
  873.     X#endif
  874.     X
  875.     Xchar *
  876.     Xget_string_resource (res_name, res_class)
  877.     X     char *res_name, *res_class;
  878.     X{
  879.     X  XrmValue value;
  880.     X  char    *type, *p;
  881.     X  char full_name [1024], full_class [1024];
  882.     X  strcpy (full_name, progname);
  883.     X  strcat (full_name, ".");
  884.     X  strcat (full_name, res_name);
  885.     X  strcpy (full_class, progclass);
  886.     X  strcat (full_class, ".");
  887.     X  strcat (full_class, res_class);
  888.     X  if (XrmGetResource (db, full_name, full_class, &type, &value))
  889.     X    {
  890.     X      char *str = (char *) malloc (value.size + 1);
  891.     X      strncpy (str, (char *) value.addr, value.size);
  892.     X      str [value.size] = 0;
  893.     X      return str;
  894.     X    }
  895.     X  return 0;
  896.     X}
  897.     X
  898.     XBool 
  899.     Xget_boolean_resource (res_name, res_class)
  900.     X     char *res_name, *res_class;
  901.     X{
  902.     X  char *tmp, buf [100];
  903.     X  char *s = get_string_resource (res_name, res_class);
  904.     X  char *os = s;
  905.     X  if (! s) return 0;
  906.     X  for (tmp = buf; *s; s++)
  907.     X    *tmp++ = isupper (*s) ? _tolower (*s) : *s;
  908.     X  *tmp = 0;
  909.     X  free (os);
  910.     X
  911.     X  if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes"))
  912.     X    return 1;
  913.     X  if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no"))
  914.     X    return 0;
  915.     X  fprintf (stderr, "%s: %s must be boolean, not %s.\n",
  916.     X       progname, res_class, buf);
  917.     X  return 0;
  918.     X}
  919.     X
  920.     Xint 
  921.     Xget_integer_resource (res_name, res_class)
  922.     X     char *res_name, *res_class;
  923.     X{
  924.     X  int val;
  925.     X  char *s = get_string_resource (res_name, res_class);
  926.     X  if (!s) return 0;
  927.     X  if (1 == sscanf (s, " %d %c", &val))
  928.     X    {
  929.     X      free (s);
  930.     X      return val;
  931.     X    }
  932.     X  fprintf (stderr, "%s: %s must be an integer, not %s.\n",
  933.     X       progname, res_name, s);
  934.     X  free (s);
  935.     X  return 0;
  936.     X}
  937.     X
  938.     Xunsigned int
  939.     Xget_pixel_resource (res_name, res_class, dpy, cmap)
  940.     X     char *res_name, *res_class;
  941.     X     Display *dpy;
  942.     X     Colormap cmap;
  943.     X{
  944.     X  int val;
  945.     X  XColor color;
  946.     X  char *s = get_string_resource (res_name, res_class);
  947.     X  if (!s) goto DEFAULT;
  948.     X
  949.     X  if (! XParseColor (dpy, cmap, s, &color))
  950.     X    {
  951.     X      fprintf (stderr, "%s: can't parse color %s\n", progname, s);
  952.     X      goto DEFAULT;
  953.     X    }
  954.     X  if (! XAllocColor (dpy, cmap, &color))
  955.     X    {
  956.     X      fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s);
  957.     X      goto DEFAULT;
  958.     X    }
  959.     X  free (s);
  960.     X  return color.pixel;
  961.     X DEFAULT:
  962.     X  free (s);
  963.     X  return (strcmp (res_class, "Background")
  964.     X      ? WhitePixel (dpy, DefaultScreen (dpy))
  965.     X      : BlackPixel (dpy, DefaultScreen (dpy)));
  966.     X}
  967. SHAR_EOF
  968. if test 3123 -ne "`wc -c < 'resources.c'`"
  969. then
  970.     echo shar: error transmitting "'resources.c'" '(should have been 3123 characters)'
  971. fi
  972. fi # end of overwriting check
  973. echo shar: extracting "'usleep.c'" '(2381 characters)'
  974. if test -f 'usleep.c'
  975. then
  976.     echo shar: will not over-write existing file "'usleep.c'"
  977. else
  978. sed 's/^    X//' << \SHAR_EOF > 'usleep.c'
  979.     X/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@lucid.com>
  980.     X *
  981.     X * Permission to use, copy, modify, distribute, and sell this software and its
  982.     X * documentation for any purpose is hereby granted without fee, provided that
  983.     X * the above copyright notice appear in all copies and that both that
  984.     X * copyright notice and this permission notice appear in supporting
  985.     X * documentation.  No representations are made about the suitability of this
  986.     X * software for any purpose.  It is provided "as is" without express or 
  987.     X * implied warranty.
  988.     X */
  989.     X
  990.     X#include <X11/Xlib.h>
  991.     X#include <X11/Xos.h>    /* lazy way out */
  992.     X
  993.     X/* usleep() doesn't exist everywhere, and select() is faster anyway.
  994.     X */
  995.     X
  996.     X#ifndef VMS
  997.     X
  998.     X#ifdef NO_SELECT
  999.     X  /* If you don't have select() or usleep(), I guess you lose...
  1000.     X     Maybe you have napms() instead?  Let me know.
  1001.     X   */
  1002.     Xvoid
  1003.     Xscreenhack_usleep (usecs)
  1004.     X     unsigned long usecs;
  1005.     X{
  1006.     X  usleep (usecs);
  1007.     X}
  1008.     X
  1009.     X#else /* ! NO_SELECT */
  1010.     X
  1011.     Xvoid
  1012.     Xscreenhack_usleep (usecs)
  1013.     X     unsigned long usecs;
  1014.     X{
  1015.     X  struct timeval tv;
  1016.     X  tv.tv_sec  = usecs / 1000000L;
  1017.     X  tv.tv_usec = usecs % 1000000L;
  1018.     X  (void) select (0, 0, 0, 0, &tv);
  1019.     X}
  1020.     X
  1021.     X#endif /* ! NO_SELECT */
  1022.     X
  1023.     X#else /* VMS */
  1024.     X
  1025.     X#define SEC_DELTA  "0000 00:00:01.00"
  1026.     X#define TICK_DELTA "0000 00:00:00.08"
  1027.     Xstatic int bin_sec_delta[2], bin_tick_delta[2], deltas_set = 0;
  1028.     X
  1029.     Xstatic void
  1030.     Xset_deltas ()
  1031.     X{
  1032.     X  int status;
  1033.     X  extern int SYS$BINTIM ();
  1034.     X  $DESCRIPTOR (str_sec_delta,  SEC_DELTA);
  1035.     X  $DESCRIPTOR (str_tick_delta, TICK_DELTA);
  1036.     X  if (!deltas_set)
  1037.     X    {
  1038.     X      status = SYS$BINTIM (&str_sec_delta, &bin_sec_delta);
  1039.     X      if (!(status & 1))
  1040.     X    {
  1041.     X      fprintf (stderr, "%s: cannot convert delta time ", progname);
  1042.     X      fprintf (stderr, SEC_DELTA);
  1043.     X      fprintf (stderr, "; status code = %d\n", status);
  1044.     X      exit (status);
  1045.     X    }
  1046.     X      status = SYS$BINTIM (&str_tick_delta, &bin_tick_delta);
  1047.     X      if (!(status & 1))
  1048.     X    {
  1049.     X      fprintf (stderr, "%s: cannot convert delta time ", progname);
  1050.     X      fprintf (stderr, TICK_DELTA);
  1051.     X      fprintf (stderr, "; status code = %d\n", status);
  1052.     X      exit (status);
  1053.     X    }
  1054.     X      deltas_set = 1;
  1055.     X    }
  1056.     X}
  1057.     X
  1058.     Xvoid
  1059.     Xscreenhack_usleep (usecs)
  1060.     X     unsigned long usecs;
  1061.     X{
  1062.     X  int status, *bin_delta;
  1063.     X  extern int SYS$SCHWDK (), SYS$HIBER (); 
  1064.     X  
  1065.     X  if (!deltas_set) set_deltas ();
  1066.     X  bin_delta = (usecs == TICK_INTERVAL) ? &bin_tick_delta : &bin_sec_delta;
  1067.     X  status = SYS$SCHDWK (0, 0, bin_delta, 0);
  1068.     X  if ((status & 1)) (void) SYS$HIBER ();
  1069.     X}
  1070.     X
  1071.     X#endif /*VMS */
  1072. SHAR_EOF
  1073. if test 2381 -ne "`wc -c < 'usleep.c'`"
  1074. then
  1075.     echo shar: error transmitting "'usleep.c'" '(should have been 2381 characters)'
  1076. fi
  1077. fi # end of overwriting check
  1078. echo shar: extracting "'xmas.c'" '(15642 characters)'
  1079. if test -f 'xmas.c'
  1080. then
  1081.     echo shar: will not over-write existing file "'xmas.c'"
  1082. else
  1083. sed 's/^    X//' << \SHAR_EOF > 'xmas.c'
  1084.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1085.     X**
  1086.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1087.     X** documentation for any purpose is hereby granted without fee, provided that
  1088.     X** the above copyright notice appear in all copies and that both that
  1089.     X** copyright notice and this permission notice appear in supporting
  1090.     X** documentation.  No representations are made about the suitability of this
  1091.     X** software for any purpose.  It is provided "as is" without express or 
  1092.     X** implied warranty.
  1093.     X**/
  1094.     X
  1095.     X/*
  1096.     X** HERSTORY:
  1097.     X13 December 92:
  1098.     XFinally got the snow code working, more or less.
  1099.     X
  1100.     X11 December 92:
  1101.     XSwitched a couple of lines to draw the candy last.
  1102.     X
  1103.     XSnow tended to ablate canes and ornaments. I added code to copy the window
  1104.     Xto an XImage during initialization, which allows me to restore the correct
  1105.     Xpixel value after snow leaves a pixel.
  1106.     X
  1107.     X10 December 92:
  1108.     XAdded beautiful snowfall code.
  1109.     X
  1110.     XAdded extra command-line options to ignore misspellings.
  1111.     X
  1112.     XAdded code to support backing store.
  1113.     X
  1114.     XAdded ornaments.
  1115.     X
  1116.     X9 December 92:
  1117.     XMoved color and snow code to modules of their own.
  1118.     X
  1119.     XMoved gift-drawing code to another file.
  1120.     X
  1121.     XMoved cane-drawing code to another file. I'm finally starting to clean
  1122.     Xup the code a little.
  1123.     X
  1124.     XAdded -snow option. I think I'm getting carried away here.
  1125.     X
  1126.     X8 December 92:
  1127.     XAdded code to draw candycanes randomly, if the user requests them.
  1128.     X
  1129.     XMoved the triangle code into its own module to clean things up a little.
  1130.     X
  1131.     XAdded #defines for the default resource values so it'll be easier to
  1132.     Xupdate the usage message when a default value changes.
  1133.     X
  1134.     X7 December 92:
  1135.     XChanged xmas_blink so it redraws the star every cycle, even if the
  1136.     Xstar doesn't blink; this is a fix for obscuration. I need to do the
  1137.     Xsame thing for the gift box.
  1138.     X
  1139.     XImproved the Makefile, wrote an Imakefile, and did a README to get this
  1140.     Xthing ready to post.
  1141.     X
  1142.     XChanged screenhack so it calls a function called usage() if there are
  1143.     Xarguments left over from resource-parsing. This lets me give better
  1144.     Xerror messages.
  1145.     X
  1146.     XAdded code to draw a gift (complete with label) under the tree. It's
  1147.     Xkind of cheesy.
  1148.     X
  1149.     XAdded code to toggle the star's twinkle; by default, it doesn't.
  1150.     X
  1151.     X6 December 92:
  1152.     XAdded code to let users change seed that generates the lights and other
  1153.     Xstuff.
  1154.     X
  1155.     XAdded support for the -install option; it's no longer good enough to use
  1156.     Xthe default colormap.
  1157.     X*/
  1158.     X
  1159.     X#include <stdio.h>
  1160.     X#include <math.h>
  1161.     X#include <X11/Xlib.h>
  1162.     X#include "screenhack.h"
  1163.     X#include "vroot.h"
  1164.     X#include "xmas.h"
  1165.     X
  1166.     X/*
  1167.     X** These arrays are our lights: their X and Y positions, their color,
  1168.     X** and whether or not they were lit last cycle.
  1169.     X*/
  1170.     Xstatic int           Xs[NUM_LIGHTS];
  1171.     Xstatic int           Ys[NUM_LIGHTS];
  1172.     Xstatic unsigned long Cs[NUM_LIGHTS];
  1173.     Xstatic int           Lit[NUM_LIGHTS];
  1174.     X
  1175.     X/*
  1176.     X** Graphics contexts. We use a separate one for the star because it
  1177.     X** needs a 0 line width, while the lights are 2 pixels wide, and I
  1178.     X** didn't want to screw with changing the line attributes all the 
  1179.     X** time.
  1180.     X*/
  1181.     Xstatic GC theGC;
  1182.     Xstatic GC StarGC;
  1183.     X
  1184.     X/*
  1185.     X** Dimensions of the window.
  1186.     X*/
  1187.     Xstatic int Width;
  1188.     Xstatic int Height;
  1189.     X
  1190.     X/*
  1191.     X** Records the state of the star.
  1192.     X*/
  1193.     Xstatic int StarLight;
  1194.     X
  1195.     X/*
  1196.     X** Does the star blink?
  1197.     X*/
  1198.     Xstatic int StarBlinks;
  1199.     X
  1200.     X/*
  1201.     X** The star's points, cached so we don't have to recalc every time.
  1202.     X*/
  1203.     Xstatic int StarX[5];
  1204.     Xstatic int StarY[5];
  1205.     X
  1206.     X/*
  1207.     X** These variables are referenced by screenhack; they're used to grab
  1208.     X** resource values, etc.
  1209.     X*/
  1210.     Xchar *progclass = "Xmas";
  1211.     X
  1212.     X/*
  1213.     X** I'd like for the usage message to automagically know about changes
  1214.     X** in the default values, but that's tough to do because of the way
  1215.     X** Xlib handles resources. So...if you change a default, change the
  1216.     X** corresponding #define. Otherwise our poor users will be confused.
  1217.     X** All of the #defines need to be strings except for DEF_DELAY,
  1218.     X** DEF_SEED, and DEF_CANDYCANES, which should be ints. 
  1219.     X** (An ANSI compiler would handle this a lot better.)
  1220.     X*/
  1221.     Xchar *defaults[] = 
  1222.     X    {
  1223.     X    "*background: black",
  1224.     X    "*starColor: yellow",
  1225.     X    "*starBlinks: false",
  1226.     X    "*delay: 1500",
  1227.     X    "*seed: 131",
  1228.     X    "*giftLabel: Nobody",
  1229.     X    "*giftColor: blue",
  1230.     X    "*giftLabelColor: white",
  1231.     X    "*numCandycanes: 0",
  1232.     X    "*snow: false",
  1233.     X    "*numOrnaments: 0",
  1234.     X    "*backingStore: true",
  1235.     X    NULL
  1236.     X    };
  1237.     X
  1238.     X/*
  1239.     X** Some of these are duplicated. The capitalization conventions
  1240.     X** in X confuse people, so I'm trying to cover a lot of the cases.
  1241.     X*/
  1242.     XXrmOptionDescRec options[] =
  1243.     X    {
  1244.     X        { "-background", ".background", XrmoptionSepArg, 0 },
  1245.     X        { "-starColor", ".starColor", XrmoptionSepArg, 0 },
  1246.     X        { "-starBlinks", ".starBlinks", XrmoptionNoArg, "True" },
  1247.     X        { "-delay", ".delay", XrmoptionSepArg, 0 },
  1248.     X        { "-seed", ".seed", XrmoptionSepArg, 0 },
  1249.     X        { "-giftLabel", ".giftLabel", XrmoptionSepArg, 0 },
  1250.     X        { "-giftlabel", ".giftLabel", XrmoptionSepArg, 0 },
  1251.     X        { "-giftColor", ".giftColor", XrmoptionSepArg, 0 },
  1252.     X        { "-giftcolor", ".giftColor", XrmoptionSepArg, 0 },
  1253.     X        { "-giftLabelColor", ".giftLabelColor", XrmoptionSepArg, 0 },
  1254.     X        { "-numCandycanes", ".numCandycanes", XrmoptionSepArg, 0 },
  1255.     X        { "-numCandyCanes", ".numCandycanes", XrmoptionSepArg, 0 },
  1256.     X        { "-candycanes", ".numCandycanes", XrmoptionSepArg, 0 },
  1257.     X        { "-snow", ".snow", XrmoptionNoArg, "True" },
  1258.     X        { "-numOrnaments", ".numOrnaments", XrmoptionSepArg, 0 },
  1259.     X        { "-numornaments", ".numOrnaments", XrmoptionSepArg, 0 },
  1260.     X        { "-ornaments", ".numOrnaments", XrmoptionSepArg, 0 },
  1261.     X        { "-backingStore", ".backingStore", XrmoptionSepArg, 0 }
  1262.     X    };
  1263.     X
  1264.     Xint options_size = (sizeof(options) / sizeof(options[0]));
  1265.     X
  1266.     X/*
  1267.     X** A better usage message. Pass it the arg count and the arg vector.
  1268.     X*/
  1269.     Xvoid usage(argc, argv)
  1270.     Xint  argc;
  1271.     Xchar **argv;
  1272.     X{
  1273.     Xint i;
  1274.     X
  1275.     Xfprintf(stderr, "XMAS Release %s\n", RELEASE);
  1276.     Xif ( strcmp(argv[1], "-help") )
  1277.     X    {
  1278.     X    fprintf(stderr, "Invalid %s: ", ( argc > 2 ? "options" : "option"));
  1279.     X    for ( i = 1; i < argc; i++ )
  1280.     X        fprintf(stderr, "%s ", argv[i]);
  1281.     X    fprintf(stderr, "\n");    
  1282.     X    }
  1283.     Xfprintf(stderr, "Usage: %s [-option...]\n", *argv);
  1284.     Xfprintf(stderr, "where valid options are:\n");
  1285.     Xfprintf(stderr, "\t-display        <display -name>    (default is %s)\n",
  1286.     X        XDisplayName(NULL));
  1287.     Xfprintf(stderr, "\t-root                              (display on root window)\n");
  1288.     Xfprintf(stderr, "\t-window                            (this is the default)\n");
  1289.     Xfprintf(stderr, 
  1290.     X        "\t-mono                              (for monochrome displays)\n");
  1291.     Xfprintf(stderr, "\t-install                           (create colormap)\n");
  1292.     Xfprintf(stderr, "\t-background     <background-color> (default is %s)\n",
  1293.     X        DEF_BG);
  1294.     Xfprintf(stderr, "\t-starColor      <star-color>       (default is %s)\n",
  1295.     X        DEF_STARCOLOR);
  1296.     Xfprintf(stderr, 
  1297.     X        "\t-starBlinks                        (default is %s)\n",
  1298.     X        DEF_STARBLINKS);
  1299.     Xfprintf(stderr, "\t-delay          <delay-ms>         (default is %dms)\n",
  1300.     X        DEF_DELAY);
  1301.     Xfprintf(stderr, "\t-seed           <random-seed>      (default is %d)\n",
  1302.     X        DEF_SEED);
  1303.     Xfprintf(stderr, "\t-giftLabel      <recipient>        (default is %s)\n",
  1304.     X        DEF_GIFTLABEL);
  1305.     Xfprintf(stderr, "\t-giftLabelColor <label-color>      (default is %s)\n",
  1306.     X        DEF_GIFTLABELCOLOR);
  1307.     Xfprintf(stderr, "\t-giftColor      <gift-color>       (default is %s)\n",
  1308.     X        DEF_GIFTCOLOR);
  1309.     Xfprintf(stderr, "\t-numCandycanes  <number-of-canes>  (default is %d)\n",
  1310.     X        DEF_NUM_CANDYCANES);
  1311.     Xfprintf(stderr, "\t-snow                              (default is %s)\n",
  1312.     X        DEF_SNOW);
  1313.     Xfprintf(stderr, "\t-numOrnaments   <num-of-ornaments> (default is %d)\n",
  1314.     X        DEF_NUM_ORNAMENTS);
  1315.     Xfprintf(stderr, "\t-backingStore   <True or False>    (default is %s)\n",
  1316.     X        DEF_BACKING_STORE);
  1317.     Xfprintf(stderr, "Example: %s -giftLabel Elvis -delay 2000\n", *argv);
  1318.     X}
  1319.     X
  1320.     X/*
  1321.     X** This is screenhack's entry to this application. It grabs any resource
  1322.     X** values the user entered and enters an infinite loop in which it
  1323.     X** first checks to see if the window has changed, initializing the tree
  1324.     X** if so; blinks the lights; and sleeps for the specified delay time.
  1325.     X*/
  1326.     Xvoid screenhack(dpy, win)
  1327.     XDisplay *dpy;
  1328.     XWindow  win;
  1329.     X{
  1330.     Xunsigned long        bg;              /* background color */
  1331.     Xunsigned long        star_color;      /* star color */
  1332.     Xint                  star_blinks;     /* does star blink? */
  1333.     Xint                  delay;           /* blink time in ms */
  1334.     Xlong                 seed;            /* seed for random number generator */
  1335.     Xchar                 *gift;           /* name for gift */
  1336.     Xunsigned long        gift_color;      /* what color's the gift? */
  1337.     Xunsigned long        gift_lbl_color;  /* color of gift label */
  1338.     Xint                  n_canes;         /* number of candy canes */
  1339.     Xint                  snow;            /* white christmas? */
  1340.     Xint                  n_ornaments;     /* number of ornaments */
  1341.     Xint                  backing_store;   /* use backing store? */
  1342.     XXWindowAttributes    win_attr;        /* window info */
  1343.     XXSetWindowAttributes win_vals;        /* used if we set backing store */
  1344.     Xint                  first_cycle = 1; /* first cycle? */
  1345.     Xint                  timecount = 0;   /* count cycle times */
  1346.     X
  1347.     Xbacking_store = get_boolean_resource("backingStore", "BackingStore");
  1348.     Xif ( backing_store )
  1349.     X    {
  1350.     X    win_vals.backing_store  = WhenMapped;
  1351.     X    win_vals.backing_planes = AllPlanes;
  1352.     X    XChangeWindowAttributes(dpy, win, 
  1353.     X                            CWBackingStore | CWBackingPlanes, &win_vals);
  1354.     X    }
  1355.     X
  1356.     Xdelay = get_integer_resource("delay", "Delay");
  1357.     Xdelay *= 1000;
  1358.     Xseed = get_integer_resource("seed", "Seed");
  1359.     Xstar_blinks = get_boolean_resource("starBlinks", "StarBlinks");
  1360.     Xgift = get_string_resource("giftLabel", "GiftLabel");
  1361.     Xn_canes = get_integer_resource("numCandycanes", "NumCandycanes");
  1362.     Xsnow = get_boolean_resource("snow", "Snow");
  1363.     Xn_ornaments = get_integer_resource("numOrnaments", "NumOrnaments");
  1364.     X
  1365.     Xwhile ( 1 )
  1366.     X    {
  1367.     X    XGetWindowAttributes(dpy, win, &win_attr);
  1368.     X/*
  1369.     X** screenhack.c does an XSync(), but it doesn't always make the window
  1370.     X** viewable in time for the XGetImage() in snow.c to work. I'm trying to
  1371.     X** fix it here by looping until the window is up on the screen.
  1372.     X*/
  1373.     X    while ( win_attr.map_state != IsViewable )
  1374.     X        XGetWindowAttributes(dpy, win, &win_attr);
  1375.     X
  1376.     X    if ( (win_attr.width != Width) || (win_attr.height != Height) )
  1377.     X        {
  1378.     X        if ( first_cycle )
  1379.     X            {
  1380.     X            first_cycle = 0;
  1381.     X            bg = get_pixel_resource("background", "Background",
  1382.     X                                    dpy, win_attr.colormap);
  1383.     X            star_color = get_pixel_resource("starColor", "StarColor", 
  1384.     X                                            dpy, win_attr.colormap);
  1385.     X            gift_color = get_pixel_resource("giftColor", "GiftColor",
  1386.     X                                            dpy, win_attr.colormap);
  1387.     X            gift_lbl_color = 
  1388.     X               get_pixel_resource("giftLabelColor", "GiftLabelColor",
  1389.     X                                  dpy, win_attr.colormap);
  1390.     X            }
  1391.     X        xmas_init(dpy, win, bg, star_color, 
  1392.     X                  win_attr.width, win_attr.height, seed, 
  1393.     X                  win_attr.colormap, star_blinks, 
  1394.     X                  gift, gift_color, gift_lbl_color, 
  1395.     X                  n_canes, n_ornaments);
  1396.     X        if ( snow )
  1397.     X            snow_init(dpy, win, win_attr.width, win_attr.height);
  1398.     X        }
  1399.     X
  1400.     X    if ( snow )
  1401.     X        {
  1402.     X        if ( (timecount += SNOWFALL_TIME) >= delay )
  1403.     X            {
  1404.     X            xmas_blink(dpy, win);
  1405.     X            timecount = 0;
  1406.     X            }
  1407.     X        draw_snow(dpy, win, win_attr.width, win_attr.height);
  1408.     X        usleep(SNOWFALL_TIME);
  1409.     X        }
  1410.     X    else
  1411.     X        {
  1412.     X        xmas_blink(dpy, win);
  1413.     X        usleep(delay);
  1414.     X        }
  1415.     X    }
  1416.     X}
  1417.     X
  1418.     X/*
  1419.     X** Initialize the application by finding how big a window we have,
  1420.     X** calculating the tree's dimensions, the positions of the lights, etc.
  1421.     X*/
  1422.     Xint xmas_init(dpy, win, bg, star_color, width, height, seed, 
  1423.     X              cmap, star_blinks, gift, gift_color, gift_lbl_color, 
  1424.     X              num_canes, num_ornaments)
  1425.     XDisplay       *dpy;            /* display connection */
  1426.     XWindow        win;             /* window we should draw to */
  1427.     Xunsigned long bg;              /* background color */
  1428.     Xunsigned long star_color;      /* color of star at top of tree */
  1429.     Xint           width;           /* how wide is our window? */
  1430.     Xint           height;          /* how high is our window? */
  1431.     Xlong          seed;            /* seed for randoms */
  1432.     XColormap      cmap;            /* which colormap to use */
  1433.     Xint           star_blinks;     /* does the star blink? */
  1434.     Xchar          *gift;           /* who's the present for? */
  1435.     Xunsigned long gift_color;      /* gift color */
  1436.     Xunsigned long gift_lbl_color;  /* gift label color */
  1437.     Xint           num_canes;       /* number of candycanes */
  1438.     Xint           num_ornaments;   /* number of ornaments to draw */
  1439.     X{
  1440.     Xint       i;                   /* loop control */
  1441.     XXGCValues gcv;                 /* values for graphics context */
  1442.     Xint       star_x;              /* center of star */
  1443.     Xint       star_y;              /* Y portion of star's center */
  1444.     Xint       Xa, Ya;              /* vertex A */
  1445.     Xint       Xb, Yb;              /* vertex B */
  1446.     Xint       Xc, Yc;              /* vertex C */
  1447.     X
  1448.     XWidth      = width;
  1449.     XHeight     = height;
  1450.     XStarBlinks = star_blinks;
  1451.     X
  1452.     XStarGC = XCreateGC(dpy, win, 0, NULL);
  1453.     X
  1454.     Xgcv.line_width = LIGHT_WIDTH;
  1455.     Xgcv.foreground = bg;
  1456.     XtheGC = XCreateGC(dpy, win, GCLineWidth | GCForeground, &gcv);
  1457.     X
  1458.     XXFillRectangle(dpy, win, theGC, 0, 0, Width, Height);
  1459.     X
  1460.     Xcolor_init(dpy, cmap, bg, star_color, gift_color, gift_lbl_color);
  1461.     X
  1462.     Xsrand48((long) time((time_t *) NULL));
  1463.     X
  1464.     X/*
  1465.     X** Calculate the positions of the lights.
  1466.     X*/
  1467.     XXa = Width >> 1;
  1468.     XYa = Height / MARGIN;
  1469.     XXb = Width >> 2;
  1470.     XXc = 3 * Xb;
  1471.     XYb = Yc = Height - (Height / MARGIN);
  1472.     Xfor ( i = 0; i < NUM_LIGHTS; i++ )
  1473.     X    {
  1474.     X    pt_in_triangle(Xa, Ya, Xb, Yb, Xc, Yc, &(Xs[i]), &(Ys[i]));
  1475.     X    Cs[i] = 
  1476.     X       get_color((lrand48() % (LAST_LIGHT - FIRST_LIGHT + 1)) + FIRST_LIGHT);
  1477.     X    }
  1478.     X
  1479.     X/*
  1480.     X** Calculate the points of the star at the top of the tree. 
  1481.     X*/
  1482.     Xstar_x = Width / 2;
  1483.     Xstar_y = Height / MARGIN;
  1484.     Xfor ( i = 0; i < 5; i++ )
  1485.     X    {
  1486.     X/*
  1487.     X** We bias the angle by -90; otherwise, it looks vaguely Satanic.
  1488.     X** Not quite the Christmas message I was going for.
  1489.     X*/
  1490.     X    StarX[i] = STAR_ARM_LENGTH * cos(DEG2RAD(-90.0 + 72.0 * i)) + star_x;
  1491.     X    StarY[i] = STAR_ARM_LENGTH * sin(DEG2RAD(-90.0 + 72.0 * i)) + star_y;
  1492.     X    }
  1493.     X
  1494.     Xif ( strcmp(gift, "Nobody") )
  1495.     X    draw_gift(dpy, win, theGC, Width, Height, 
  1496.     X              gift, gift_color, gift_lbl_color);
  1497.     X
  1498.     Xif ( num_ornaments )
  1499.     X    draw_ornaments(dpy, win, theGC, Xa, Ya, Xb, Yb, Xc, Yc, num_ornaments);
  1500.     X
  1501.     Xif ( num_canes )
  1502.     X    draw_candy(dpy, win, theGC, Xa, Ya, Xb, Yb, Xc, Yc, num_canes);
  1503.     X}
  1504.     X
  1505.     X/*
  1506.     X** Blink the pretty lights and the star.
  1507.     X*/
  1508.     Xxmas_blink(dpy, win)
  1509.     XDisplay *dpy;                       /* display connection */
  1510.     XWindow  win;                        /* window ID */
  1511.     X{
  1512.     Xint i;                              /* loop control */
  1513.     Xint star_x;                         /* X part of star's center */
  1514.     Xint star_y;                         /* Y part of star's center */
  1515.     Xint lit_before;                     /* previous state of a light */
  1516.     X
  1517.     X/*
  1518.     X** Figure out what a light wants to do. If it wants to be
  1519.     X** turned off, and it was turned on last cycle, turn it off; if it's
  1520.     X** on this cycle, and wasn't on last cycle, turn it on. Otherwise
  1521.     X** ignore it. See, this is an OPTIMIZED Christmas tree. Much better
  1522.     X** than the real thing.
  1523.     X*/
  1524.     Xfor ( i = 0; i < NUM_LIGHTS; i++ )
  1525.     X    {
  1526.     X    lit_before = Lit[i];
  1527.     X    Lit[i] = lrand48() % 2;
  1528.     X    if ( lit_before && !Lit[i] )
  1529.     X        {
  1530.     X        XSetForeground(dpy, theGC, get_color(BACKGROUND));
  1531.     X        XDrawLine(dpy, win, theGC, 
  1532.     X                  Xs[i], Ys[i], Xs[i], Ys[i] + LIGHT_HEIGHT);
  1533.     X        }
  1534.     X    else if ( !lit_before && Lit[i] )
  1535.     X        {
  1536.     X        XSetForeground(dpy, theGC, Cs[i]);
  1537.     X        XDrawLine(dpy, win, theGC, 
  1538.     X                  Xs[i], Ys[i], Xs[i], Ys[i] + LIGHT_HEIGHT);
  1539.     X        }
  1540.     X    }
  1541.     X
  1542.     X/*
  1543.     X** Draw a twinkling star on top of the tree.
  1544.     X*/
  1545.     Xif ( StarBlinks )
  1546.     X    {
  1547.     X    star_x = Width / 2;
  1548.     X    star_y = Height / MARGIN;
  1549.     X    XSetForeground(dpy, StarGC, 
  1550.     X                   StarLight ? get_color(BACKGROUND) : get_color(STARCOLOR));
  1551.     X    for ( i = 0; i < 5; i++ )
  1552.     X        {
  1553.     X        XDrawLine(dpy, win, StarGC, star_x, star_y, StarX[i], StarY[i]);
  1554.     X        }
  1555.     X    StarLight = 1 - StarLight;
  1556.     X    }
  1557.     X}
  1558. SHAR_EOF
  1559. if test 15642 -ne "`wc -c < 'xmas.c'`"
  1560. then
  1561.     echo shar: error transmitting "'xmas.c'" '(should have been 15642 characters)'
  1562. fi
  1563. fi # end of overwriting check
  1564. echo shar: extracting "'pt_in_tri.c'" '(1264 characters)'
  1565. if test -f 'pt_in_tri.c'
  1566. then
  1567.     echo shar: will not over-write existing file "'pt_in_tri.c'"
  1568. else
  1569. sed 's/^    X//' << \SHAR_EOF > 'pt_in_tri.c'
  1570.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1571.     X**
  1572.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1573.     X** documentation for any purpose is hereby granted without fee, provided that
  1574.     X** the above copyright notice appear in all copies and that both that
  1575.     X** copyright notice and this permission notice appear in supporting
  1576.     X** documentation.  No representations are made about the suitability of this
  1577.     X** software for any purpose.  It is provided "as is" without express or 
  1578.     X** implied warranty.
  1579.     X**/
  1580.     X
  1581.     X#include <math.h>
  1582.     X
  1583.     Xdouble drand48();
  1584.     X
  1585.     X/*
  1586.     X** Algorithm for random points in a triangle is from Glassner's _Graphics
  1587.     X** Gems_ (Academic Press, 1990). It's a book worth getting.
  1588.     X*/
  1589.     Xvoid pt_in_triangle(Xa, Ya, Xb, Yb, Xc, Yc, x_ptr, y_ptr)
  1590.     Xint Xa, Ya;           /* first vertex */
  1591.     Xint Xb, Yb;           /* second vertex */
  1592.     Xint Xc, Yc;           /* third vertex */
  1593.     Xint *x_ptr, *y_ptr;   /* where to store point */
  1594.     X{
  1595.     Xdouble s, t;          /* two random numbers on [0.0,1.0] */
  1596.     Xdouble a;             /* barycentric coordinate (s and t are the others) */
  1597.     X
  1598.     Xs = drand48();
  1599.     Xt = drand48();
  1600.     Xif ( (s + t) > 1 )
  1601.     X    {
  1602.     X    s = 1 - s;
  1603.     X    t = 1 - t;
  1604.     X    }
  1605.     Xa = 1.0 - s - t;
  1606.     X*x_ptr = a * Xa + s * Xb + t * Xc;
  1607.     X*y_ptr = a * Ya + s * Yb + t * Yc;
  1608.     X}
  1609. SHAR_EOF
  1610. if test 1264 -ne "`wc -c < 'pt_in_tri.c'`"
  1611. then
  1612.     echo shar: error transmitting "'pt_in_tri.c'" '(should have been 1264 characters)'
  1613. fi
  1614. fi # end of overwriting check
  1615. echo shar: extracting "'candy.c'" '(1830 characters)'
  1616. if test -f 'candy.c'
  1617. then
  1618.     echo shar: will not over-write existing file "'candy.c'"
  1619. else
  1620. sed 's/^    X//' << \SHAR_EOF > 'candy.c'
  1621.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1622.     X**
  1623.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1624.     X** documentation for any purpose is hereby granted without fee, provided that
  1625.     X** the above copyright notice appear in all copies and that both that
  1626.     X** copyright notice and this permission notice appear in supporting
  1627.     X** documentation.  No representations are made about the suitability of this
  1628.     X** software for any purpose.  It is provided "as is" without express or 
  1629.     X** implied warranty.
  1630.     X**/
  1631.     X
  1632.     X#include <X11/Xlib.h>
  1633.     X#include "xmas.h"
  1634.     X
  1635.     X/*
  1636.     X** Draw a set of candycanes inside a triangle. 
  1637.     X*/
  1638.     Xvoid draw_candy(dpy, win, gc, Xa, Ya, Xb, Yb, Xc, Yc, num_canes)
  1639.     XDisplay  *dpy;             /* connection to display */
  1640.     XWindow   win;              /* window ID */
  1641.     XGC       gc;               /* graphics context */
  1642.     Xint      Xa, Ya;           /* vertex A of triangle */
  1643.     Xint      Xb, Yb;           /* vertex B of triangle */
  1644.     Xint      Xc, Yc;           /* vertex C of triangle */
  1645.     Xint      num_canes;        /* number of candycanes to draw */
  1646.     X{
  1647.     XXGCValues gcv;             /* values for XChangeGC() */
  1648.     Xint       i;               /* loop control */
  1649.     Xint       candy_x;         /* X coord of candycane's origin */
  1650.     Xint       candy_y;         /* Y coord of candycane's origin */
  1651.     X
  1652.     Xgcv.foreground = get_color(RED);
  1653.     Xgcv.background = get_color(WHITE);
  1654.     Xgcv.line_style = LineDoubleDash;
  1655.     XXChangeGC(dpy, gc, GCForeground | GCBackground | GCLineStyle, &gcv);
  1656.     X
  1657.     Xfor ( i = 0; i < num_canes; i++ )
  1658.     X    {
  1659.     X    pt_in_triangle(Xa, Ya, Xb, Yb, Xc, Yc, &candy_x, &candy_y);
  1660.     X    XDrawArc(dpy, win, gc, candy_x, candy_y, 
  1661.     X             DEF_CANDY_WIDTH, DEF_CANDY_HEIGHT, 0, HALF_CIRCLE);
  1662.     X    XDrawLine(dpy, win, gc,
  1663.     X              candy_x + DEF_CANDY_WIDTH, candy_y, 
  1664.     X              candy_x + DEF_CANDY_WIDTH, candy_y + DEF_CANDY_LENGTH);
  1665.     X    }
  1666.     X}
  1667. SHAR_EOF
  1668. if test 1830 -ne "`wc -c < 'candy.c'`"
  1669. then
  1670.     echo shar: error transmitting "'candy.c'" '(should have been 1830 characters)'
  1671. fi
  1672. fi # end of overwriting check
  1673. echo shar: extracting "'gift.c'" '(2211 characters)'
  1674. if test -f 'gift.c'
  1675. then
  1676.     echo shar: will not over-write existing file "'gift.c'"
  1677. else
  1678. sed 's/^    X//' << \SHAR_EOF > 'gift.c'
  1679.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1680.     X**
  1681.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1682.     X** documentation for any purpose is hereby granted without fee, provided that
  1683.     X** the above copyright notice appear in all copies and that both that
  1684.     X** copyright notice and this permission notice appear in supporting
  1685.     X** documentation.  No representations are made about the suitability of this
  1686.     X** software for any purpose.  It is provided "as is" without express or 
  1687.     X** implied warranty.
  1688.     X**/
  1689.     X
  1690.     X#include <X11/Xlib.h>
  1691.     X#include "xmas.h"
  1692.     X
  1693.     X/*
  1694.     X** Draw a gift under the tree. This is the weakest of the xmas functions.
  1695.     X*/
  1696.     Xvoid draw_gift(dpy, win, gc, width, height, to_whom, box_color, text_color)
  1697.     XDisplay       *dpy;            /* display connection */
  1698.     XWindow        win;             /* window/pixmap */
  1699.     XGC            gc;              /* graphics context */
  1700.     Xint           width;           /* width of window */
  1701.     Xint           height;          /* height of window */
  1702.     Xchar          *to_whom;        /* for whom is the gift? */
  1703.     Xunsigned long box_color;       /* what color should the box be? */
  1704.     Xunsigned long text_color;      /* to_whom color */
  1705.     X{
  1706.     Xchar        tag[64];           /* formatted tag for gift */
  1707.     XXFontStruct *font_sp;          /* font info */
  1708.     Xint         dir;               /* string direction */
  1709.     Xint         asc;               /* max string ascent */
  1710.     Xint         dec;               /* max string descent */
  1711.     XXCharStruct ovr;               /* overall string info */
  1712.     Xint         gift_width;        /* gift is sized to fit tag */
  1713.     Xint         gift_height;       /* height of gift */
  1714.     X
  1715.     Xsprintf(tag, "To: %s", to_whom);
  1716.     Xfont_sp = XLoadQueryFont(dpy, "fixed");
  1717.     XXQueryTextExtents(dpy, font_sp->fid, tag, strlen(tag),
  1718.     X                  &dir, &asc, &dec, &ovr);
  1719.     Xgift_width = ovr.lbearing + ovr.width;
  1720.     Xgift_height = asc + dec;
  1721.     XXSetForeground(dpy, gc, box_color);
  1722.     XXSetFont(dpy, gc, font_sp->fid);
  1723.     XXFillRectangle(dpy, win, gc, width / 2 + 10, height - gift_height - 10,
  1724.     X               gift_width, gift_height);
  1725.     XXSetForeground(dpy, gc, text_color);
  1726.     XXDrawString(dpy, win, gc,
  1727.     X            width / 2 + 10 + ovr.lbearing, height - 10 - dec,
  1728.     X            tag, strlen(tag));
  1729.     X}
  1730. SHAR_EOF
  1731. if test 2211 -ne "`wc -c < 'gift.c'`"
  1732. then
  1733.     echo shar: error transmitting "'gift.c'" '(should have been 2211 characters)'
  1734. fi
  1735. fi # end of overwriting check
  1736. echo shar: extracting "'snow.c'" '(3388 characters)'
  1737. if test -f 'snow.c'
  1738. then
  1739.     echo shar: will not over-write existing file "'snow.c'"
  1740. else
  1741. sed 's/^    X//' << \SHAR_EOF > 'snow.c'
  1742.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1743.     X**
  1744.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1745.     X** documentation for any purpose is hereby granted without fee, provided that
  1746.     X** the above copyright notice appear in all copies and that both that
  1747.     X** copyright notice and this permission notice appear in supporting
  1748.     X** documentation.  No representations are made about the suitability of this
  1749.     X** software for any purpose.  It is provided "as is" without express or 
  1750.     X** implied warranty.
  1751.     X**/
  1752.     X
  1753.     X#include <stdio.h>
  1754.     X#include <X11/Xlib.h>
  1755.     X#include <math.h>
  1756.     X#include "xmas.h"
  1757.     X
  1758.     X/*
  1759.     X** Arrays of snowflake coordinates.
  1760.     X*/
  1761.     Xstatic int Xs[NUM_SNOWFLAKES];
  1762.     Xstatic int Ys[NUM_SNOWFLAKES];
  1763.     X
  1764.     X/*
  1765.     X** Snow piles up at the bottom of the window. This array keeps track
  1766.     X** of how high the snow is. Since the window's size can change, this
  1767.     X** thing needs to be dynamically resized based on the width in pixels
  1768.     X** of the window.
  1769.     X*/
  1770.     Xstatic int *Snowfall = NULL;
  1771.     X
  1772.     X/*
  1773.     X** Graphics contexts. These have to change way too many times to restore
  1774.     X** the correct background pixel values.
  1775.     X*/
  1776.     Xstatic GC SnowGC;
  1777.     Xstatic GC BackgroundGC;
  1778.     X
  1779.     X/*
  1780.     X** When we snow through something, we need to know what color we
  1781.     X** snowed through so we can restore it. There's no way to retrieve
  1782.     X** pixel information from a window, so we create an XImage of the
  1783.     X** window and restore from it.
  1784.     X*/
  1785.     Xstatic XImage *WindowImage = NULL;
  1786.     X
  1787.     X/*
  1788.     X** Fill the snowflake arrays with initial values. I start the snow 
  1789.     X** "above" the window so you don't see a mass of it at the top of 
  1790.     X** the screen.
  1791.     X*/
  1792.     Xvoid snow_init(dpy, win, width, height)
  1793.     XDisplay *dpy;        /* display connection */
  1794.     XWindow  win;         /* window ID */
  1795.     Xint     width;       /* width of window we snow in */
  1796.     Xint     height;      /* height of window we snow in */
  1797.     X{
  1798.     Xint       i;         /* loop control */
  1799.     XXGCValues gcv;       /* values for GC */
  1800.     X
  1801.     Xif ( WindowImage != NULL )
  1802.     X    XDestroyImage(WindowImage);
  1803.     XWindowImage = XGetImage(dpy, win, 0, 0, width, height, AllPlanes, XYPixmap);
  1804.     X
  1805.     Xgcv.foreground = get_color(BACKGROUND);
  1806.     XBackgroundGC   = XCreateGC(dpy, win, GCForeground, &gcv);
  1807.     Xgcv.foreground = get_color(WHITE);
  1808.     XSnowGC         = XCreateGC(dpy, win, GCForeground, &gcv);
  1809.     X
  1810.     Xfor ( i = 0; i < NUM_SNOWFLAKES; i++ )
  1811.     X    {
  1812.     X    Xs[i] = lrand48() % width;
  1813.     X    Ys[i] = SNOW_START;
  1814.     X    }
  1815.     Xif ( Snowfall != NULL )
  1816.     X    free(Snowfall);
  1817.     Xif ( (Snowfall = (int *) calloc(width, sizeof(int))) == NULL )
  1818.     X    fprintf(stderr, "Can't allocate space for %d ints\n", width);
  1819.     X}
  1820.     X
  1821.     X/*
  1822.     X** Draw random snowflakes in a window.
  1823.     X*/
  1824.     Xvoid draw_snow(dpy, win, width, height)
  1825.     XDisplay *dpy;        /* display connection */
  1826.     XWindow  win;         /* window ID */
  1827.     Xint     width;       /* width of snowfield */
  1828.     Xint     height;      /* height of window */
  1829.     X{
  1830.     Xint i;               /* loop control */
  1831.     X
  1832.     Xfor ( i = 0; i < NUM_SNOWFLAKES; i++ )
  1833.     X    {
  1834.     X    if ( !(lrand48() % SNOWFLAKES_CHANCE) )
  1835.     X        {
  1836.     X        if ( Ys[i] > SNOW_START && Ys[i] < (height - Snowfall[Xs[i]]) )
  1837.     X            {
  1838.     X            XSetForeground(dpy, BackgroundGC, 
  1839.     X                           XGetPixel(WindowImage, Xs[i], Ys[i]));
  1840.     X            XDrawPoint(dpy, win, BackgroundGC, Xs[i], Ys[i]);
  1841.     X            }
  1842.     X        Ys[i] += (lrand48() % MAX_SNOWFALL_RATE);
  1843.     X        if ( Ys[i] < (height - 1) )
  1844.     X            XDrawPoint(dpy, win, SnowGC, Xs[i], Ys[i]);
  1845.     X        else
  1846.     X            {
  1847.     X            XDrawPoint(dpy, win, SnowGC, Xs[i], height - Snowfall[Xs[i]]);
  1848.     X            Snowfall[Xs[i]]++;
  1849.     X            Xs[i] = lrand48() % width;
  1850.     X            Ys[i] = SNOW_START;
  1851.     X            }
  1852.     X        }
  1853.     X    }
  1854.     X}
  1855. SHAR_EOF
  1856. if test 3388 -ne "`wc -c < 'snow.c'`"
  1857. then
  1858.     echo shar: error transmitting "'snow.c'" '(should have been 3388 characters)'
  1859. fi
  1860. fi # end of overwriting check
  1861. echo shar: extracting "'ornament.c'" '(2833 characters)'
  1862. if test -f 'ornament.c'
  1863. then
  1864.     echo shar: will not over-write existing file "'ornament.c'"
  1865. else
  1866. sed 's/^    X//' << \SHAR_EOF > 'ornament.c'
  1867.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1868.     X**
  1869.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1870.     X** documentation for any purpose is hereby granted without fee, provided that
  1871.     X** the above copyright notice appear in all copies and that both that
  1872.     X** copyright notice and this permission notice appear in supporting
  1873.     X** documentation.  No representations are made about the suitability of this
  1874.     X** software for any purpose.  It is provided "as is" without express or 
  1875.     X** implied warranty.
  1876.     X**/
  1877.     X
  1878.     X#include <stdio.h>
  1879.     X#include <X11/Xlib.h>
  1880.     X#include "xmas.h"
  1881.     X
  1882.     X/*
  1883.     X** These are the bitmap files from which we get our ornaments.
  1884.     X*/
  1885.     Xstatic char *Bitmap_files[] =
  1886.     X    {
  1887.     X    "/usr/include/X11/bitmaps/icon",
  1888.     X    "/usr/include/X11/bitmaps/keyboard16",
  1889.     X    "/usr/include/X11/bitmaps/opendot",
  1890.     X    "/usr/include/X11/bitmaps/star",
  1891.     X    "/usr/include/X11/bitmaps/target",
  1892.     X    "/usr/include/X11/bitmaps/tie_fighter",
  1893.     X    "/usr/include/X11/bitmaps/xlogo16",
  1894.     X    };
  1895.     X
  1896.     X#define NUM_BITMAPS (sizeof(Bitmap_files) / sizeof(char *))
  1897.     X
  1898.     X/*
  1899.     X** These are our ornaments. The ones I've picked are all 16 by 16.
  1900.     X*/
  1901.     Xstatic Pixmap Bitmaps[NUM_BITMAPS];
  1902.     X
  1903.     X/*
  1904.     X** Draw some ornaments on the tree.
  1905.     X*/
  1906.     Xvoid draw_ornaments(dpy, win, gc, Xa, Ya, Xb, Yb, Xc, Yc, num_ornaments)
  1907.     XDisplay  *dpy;             /* connection to display */
  1908.     XWindow   win;              /* window ID */
  1909.     XGC       gc;               /* graphics context */
  1910.     Xint      Xa, Ya;           /* vertex A of triangle */
  1911.     Xint      Xb, Yb;           /* vertex B of triangle */
  1912.     Xint      Xc, Yc;           /* vertex C of triangle */
  1913.     Xint      num_ornaments;    /* number of ornaments to draw */
  1914.     X{
  1915.     Xint       i;               /* loop control */
  1916.     Xint       orn_x;           /* X coord of ornament's origin */
  1917.     Xint       orn_y;           /* Y coord of ornament's origin */
  1918.     Xunsigned  width;           /* ornament width */
  1919.     Xunsigned  height;          /* ornament height */
  1920.     Xint       x_hot;           /* cursor hotspot's X coord */
  1921.     Xint       y_hot;           /* cursor hotspot's Y coord */
  1922.     Xint       which_bitmap;    /* which bitmap to use */
  1923.     X
  1924.     XXSetBackground(dpy, gc, get_color(BACKGROUND));
  1925.     X
  1926.     Xfor ( i = 0; i < num_ornaments; i++ )
  1927.     X    {
  1928.     X    which_bitmap = lrand48() % NUM_BITMAPS;
  1929.     X    if ( Bitmaps[which_bitmap] == NULL )
  1930.     X        {
  1931.     X        XReadBitmapFile(dpy, win, Bitmap_files[which_bitmap],
  1932.     X                        &width, &height, &(Bitmaps[which_bitmap]), 
  1933.     X                        &x_hot, &y_hot);
  1934.     X        }
  1935.     X    XSetForeground(dpy, gc, 
  1936.     X                   get_color(  (lrand48() % (LAST_LIGHT - FIRST_LIGHT + 1)) 
  1937.     X                   + FIRST_LIGHT));
  1938.     X    pt_in_triangle(Xa, Ya, Xb, Yb, Xc, Yc, &orn_x, &orn_y);
  1939.     X    XCopyPlane(dpy, Bitmaps[which_bitmap], win, gc, 
  1940.     X               0, 0, BITMAP_WIDTH, BITMAP_HEIGHT, orn_x, orn_y, 1);
  1941.     X    }
  1942.     X    
  1943.     Xfor ( i = 0; i < NUM_BITMAPS; i++ )
  1944.     X    {
  1945.     X    if ( Bitmaps[i] != NULL )
  1946.     X        XFreePixmap(dpy, Bitmaps[i]);
  1947.     X    Bitmaps[i] = NULL;
  1948.     X    }
  1949.     X}
  1950. SHAR_EOF
  1951. if test 2833 -ne "`wc -c < 'ornament.c'`"
  1952. then
  1953.     echo shar: error transmitting "'ornament.c'" '(should have been 2833 characters)'
  1954. fi
  1955. fi # end of overwriting check
  1956. echo shar: extracting "'color.c'" '(2158 characters)'
  1957. if test -f 'color.c'
  1958. then
  1959.     echo shar: will not over-write existing file "'color.c'"
  1960. else
  1961. sed 's/^    X//' << \SHAR_EOF > 'color.c'
  1962.     X/* xmas, Copyright 1992 Mitchell L. Patterson (mpatters@cs.scarolina.edu)
  1963.     X**
  1964.     X** Permission to use, copy, modify, distribute, and sell this software and its
  1965.     X** documentation for any purpose is hereby granted without fee, provided that
  1966.     X** the above copyright notice appear in all copies and that both that
  1967.     X** copyright notice and this permission notice appear in supporting
  1968.     X** documentation.  No representations are made about the suitability of this
  1969.     X** software for any purpose.  It is provided "as is" without express or 
  1970.     X** implied warranty.
  1971.     X**/
  1972.     X
  1973.     X#include <X11/Xlib.h>
  1974.     X#include "xmas.h"
  1975.     X
  1976.     X/*
  1977.     X** Internal array of pixel values; these are allocated in color_init
  1978.     X** and retrieved by users with get_color().
  1979.     X*/
  1980.     Xstatic unsigned long Colors[NUM_COLORS];
  1981.     X
  1982.     X/*
  1983.     X** Names of the colors we'll use for lights. These should parallel
  1984.     X** the colorname #defines in xmas.h.
  1985.     X*/
  1986.     Xstatic char *ColorNames[] =
  1987.     X    {
  1988.     X    "white",
  1989.     X    "red",
  1990.     X    "green",
  1991.     X    "orange",
  1992.     X    "yellow"
  1993.     X    };
  1994.     X
  1995.     X/*
  1996.     X** Initialize the color functions.
  1997.     X*/
  1998.     Xvoid color_init(dpy, cmap, bg, star_color, box_color, text_color)
  1999.     XDisplay       *dpy;           /* display connection */
  2000.     XColormap      cmap;           /* colormap */
  2001.     Xunsigned long bg;             /* background pixel */
  2002.     Xunsigned long star_color;     /* star pixel */
  2003.     Xunsigned long box_color;      /* gift pixel */
  2004.     Xunsigned long text_color;     /* text pixel */
  2005.     X{
  2006.     Xint    i;                     /* loop control */
  2007.     XXColor real;                  /* value returned by XAlloc... */
  2008.     XXColor ideal;                 /* real-world RGB values, ignored */
  2009.     X
  2010.     XColors[BACKGROUND] = bg;
  2011.     XColors[STARCOLOR]  = star_color;
  2012.     XColors[BOXCOLOR]   = box_color;
  2013.     XColors[TEXTCOLOR]  = text_color;
  2014.     X
  2015.     Xfor ( i = FIRST_LIGHT; i <= LAST_LIGHT; i++ )
  2016.     X    {
  2017.     X    XAllocNamedColor(dpy, cmap, ColorNames[i - FIRST_LIGHT], &real, &ideal);
  2018.     X    Colors[i] = real.pixel;
  2019.     X    }
  2020.     X}
  2021.     X
  2022.     X/*
  2023.     X** Retrieve a pixel from the color table. If the color number passed
  2024.     X** in is invalid, return the background color.
  2025.     X*/
  2026.     Xunsigned long get_color(which_color)
  2027.     Xint which_color;          /* xmas.h's #define for a particular color */
  2028.     X{
  2029.     Xreturn (which_color < 0 || which_color >= NUM_COLORS) ? 
  2030.     X         Colors[BACKGROUND] 
  2031.     X       : Colors[which_color];
  2032.     X}
  2033. SHAR_EOF
  2034. if test 2158 -ne "`wc -c < 'color.c'`"
  2035. then
  2036.     echo shar: error transmitting "'color.c'" '(should have been 2158 characters)'
  2037. fi
  2038. fi # end of overwriting check
  2039. echo shar: extracting "'xmas.man'" '(3274 characters)'
  2040. if test -f 'xmas.man'
  2041. then
  2042.     echo shar: will not over-write existing file "'xmas.man'"
  2043. else
  2044. sed 's/^    X//' << \SHAR_EOF > 'xmas.man'
  2045.     X.TH XMAS 1 "18 December 1992"
  2046.     X.SH NAME
  2047.     Xxmas \- Christmas display hack
  2048.     X.SH SYNOPSIS
  2049.     X.B xmas
  2050.     X[\-display \fIdisplay\fP]
  2051.     X[\-root]
  2052.     X[\-window]
  2053.     X[\-mono]
  2054.     X[\-install]
  2055.     X[\-background \fIbackground-color\fP]
  2056.     X[\-starColor \fIstar-color\fP]
  2057.     X[\-starBlinks]
  2058.     X[\-delay \fIdelay-ms\fP]
  2059.     X[\-seed \fIrandomseed\fP] 
  2060.     X[\-giftLabel \fIrecipient\fP]
  2061.     X[\-giftLabelColor \fIlabel-color\fP]
  2062.     X[\-giftColor \fIgift-color\fP]
  2063.     X[\-numCandycanes \fInumber-of-canes\fP]
  2064.     X[\-snow]
  2065.     X[\-numOrnaments \fInumber-of-ornaments\fP]
  2066.     X[\-backingStore \fIboolean\fP]
  2067.     X.SH OPTIONS
  2068.     X.PP
  2069.     X.TP 8
  2070.     X.B -display \fIdisplay\fP
  2071.     XDirect output to a server other than the default.
  2072.     X.PP
  2073.     X.TP 8
  2074.     X.B -root
  2075.     XUse the root (or virtual root) window.
  2076.     X.PP
  2077.     X.TP 8
  2078.     X.B -window
  2079.     XCreate a window. This is the default.
  2080.     X.PP
  2081.     X.TP 8
  2082.     X.B -install
  2083.     XCreate a new colormap instead of using the default colormap.
  2084.     X.PP
  2085.     X.TP 8
  2086.     X.B "-background \fIbackground-color\fP"
  2087.     XUse the named color for the window background. The default is black.
  2088.     X.PP
  2089.     X.TP 8
  2090.     X.B "-starColor \fIstar-color\fP"
  2091.     XPaint the star in the named color. The default is yellow.
  2092.     X.PP
  2093.     X.TP 8
  2094.     X.B -starBlinks
  2095.     XBlink the star every cycle. By default, the star is lit all the time.
  2096.     X.PP
  2097.     X.TP 8
  2098.     X.B "-delay \fIdelay-ms\fP"
  2099.     XChange the blink time of the lights. The default is 1500 milliseconds.
  2100.     X.PP
  2101.     X.TP 8
  2102.     X.B "-seed \fIrandomseed\fP"
  2103.     XUse the given integer seed as the initializer for light placement.
  2104.     X.PP
  2105.     X.TP 8
  2106.     X.B "-giftLabel \fIrecipient\fP"
  2107.     XDraw a present under the tree and label it with the recipient's name. The
  2108.     Xdefault is to not draw a gift.
  2109.     X.PP
  2110.     X.TP 8
  2111.     X.B "-giftLabelColor \fIlabel-color\fP"
  2112.     XDraw the label on the gift, assuming there is one, in the named color. 
  2113.     XThe default color is white.
  2114.     X.PP
  2115.     X.TP 8
  2116.     X.B "-giftColor \fIgift-color\fP"
  2117.     XDraw the gift, assuming there is one, in the named color. The default
  2118.     Xcolor is blue.
  2119.     X.PP
  2120.     X.TP 8
  2121.     X.B "-numCandycanes \fInumber-of-canes\fP"
  2122.     XDraw the given number of candycanes on the tree. The default is to 
  2123.     Xdraw no candycanes.
  2124.     X.PP
  2125.     X.TP 8
  2126.     X.B -snow
  2127.     XDraw snowfall in the background. Snowfall is pretty, but the calculations
  2128.     Xand graphics requests slurp CPU time. Snowfall also interferes with
  2129.     Xthe -delay option; delay times are roughly double what they should be
  2130.     Xwhen it's snowing.
  2131.     X.PP
  2132.     X.TP 8
  2133.     X.B "-numOrnaments \fInumber-of-ornaments\fP"
  2134.     XDraw the given number of ornaments on the tree. The default is to draw
  2135.     Xno ornaments.
  2136.     X.PP
  2137.     X.TP 8
  2138.     X.B "-backingStore \fIboolean\fP"
  2139.     XToggle the use of backing store. The default value is True, meaning
  2140.     Xbacking store should be used. Backing store is expensive in server
  2141.     Xmemory and should not be used if server resources are necessary for
  2142.     Xmore important clients.
  2143.     X.PP
  2144.     XAll of the command-line options can be specified in an X resource file
  2145.     Xsuch as
  2146.     X.I .Xdefaults
  2147.     Xby changing the leading dash to an asterisk or (more properly) by
  2148.     Xspecifying the value as follows:
  2149.     X.PP
  2150.     Xxmas.background: green
  2151.     X.PP
  2152.     XSome of the options have synonyms to keep xmas from complaining about
  2153.     Xspelling errors: "numCandycanes" can be entered on the command line
  2154.     Xas "numCandyCanes" or "candycanes"; "numOrnaments" can be entered as
  2155.     X"numornaments" or "ornaments." The synonyms do not work in resource
  2156.     Xfiles.
  2157.     X.SH DESCRIPTION
  2158.     X.I Xmas
  2159.     Xdraws a Christmas tree in its own window, or on the root window, and blinks
  2160.     Xits lights randomly. Not much else to it. 
  2161.     X.SH AUTHOR
  2162.     XMitch Patterson
  2163.     X.br
  2164.     Xmpatters@cs.scarolina.edu
  2165. SHAR_EOF
  2166. if test 3274 -ne "`wc -c < 'xmas.man'`"
  2167. then
  2168.     echo shar: error transmitting "'xmas.man'" '(should have been 3274 characters)'
  2169. fi
  2170. fi # end of overwriting check
  2171. #    End of shell archive
  2172. exit 0
  2173. --
  2174. -----------------------------------------------------------------------------
  2175.      "For who could have known -- phlegm, tons of phlegm, awaited us."
  2176.                        BOZO MADRID #23: BOZO'S GOT A COLD
  2177. Mitch Patterson - eXpert eXplorer project - patterso@usceast.cs.scarolina.edu
  2178.