http://ftp.x.org/contrib/applications/xscreensaver-2.23.tar.gz
[xscreensaver] / hacks / xroger-hack.c
index d2bc0316974deef37d6bbd5ede3dac2e6a63ce14..0138c64aee496652caff416c9c4296dd8ab11957 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@lucid.com>
+/* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 char *progclass = "XRoger";
 
 char *defaults [] = {
-  "*background: black",
-  "*foreground: red",
-  "*delay:     5",
+  ".background:                black",
+  ".foreground:                red",
+  "*delay:             5",
   0
 };
 
 XrmOptionDescRec options [] = {
-  { "-delay",          ".delay",       XrmoptionSepArg, 0 }
+  { "-delay",          ".delay",       XrmoptionSepArg, 0 },
+  { 0, 0, 0, 0 }
 };
-int options_size = (sizeof (options) / sizeof (options[0]));
 
-#if __STDC__
 extern void skull (Display *, Window, GC, GC, int, int, int, int);
-#endif
 
 void
 screenhack (dpy, window)
@@ -39,7 +37,7 @@ screenhack (dpy, window)
   Colormap cmap;
   GC draw_gc, erase_gc;
   unsigned int fg;
-  XColor color, color2;
+  XColor color, color2, color3;
   int delay = get_integer_resource ("delay", "Integer");
   XWindowAttributes xgwa;
   XGetWindowAttributes (dpy, window, &xgwa);
@@ -59,7 +57,6 @@ screenhack (dpy, window)
     {
       int w, h, ww, hh, x, y;
       time_t start_time;
-      XWindowAttributes xgwa;
       XGetWindowAttributes (dpy, window, &xgwa);
       w = xgwa.width;
       h = xgwa.height;
@@ -73,6 +70,8 @@ screenhack (dpy, window)
       x = random () % (w - ww);
       y = random () % (h - hh);
       XClearWindow (dpy, window);
+
+
       skull (dpy, window, draw_gc, erase_gc, x, y, ww, hh);
       XSync (dpy, True);
       start_time = time ((time_t *) 0);
@@ -81,17 +80,19 @@ screenhack (dpy, window)
       else
        while (start_time + delay > time ((time_t *) 0))
          {
-           int h;
-           double s, v;
+           int H;
+           double S, V;
            color2 = color;
-           rgb_to_hsv (color2.red, color2.green, color2.blue, &h, &s, &v);
-           v += delta;
-           if (v >= 1.0) v = 1.0, delta = -delta;
-           if (v <= 0.7) v = 0.7, delta = -delta;
-           hsv_to_rgb (h, s, v, &color2.red, &color2.green, &color2.blue);
-           if (XAllocColor (dpy, cmap, &color2))
+           rgb_to_hsv (color2.red, color2.green, color2.blue, &H, &S, &V);
+           V += delta;
+           if (V >= 1.0) V = 1.0, delta = -delta;
+           if (V <= 0.6) V = 0.7, delta = -delta;
+           hsv_to_rgb (H, S, V, &color2.red, &color2.green, &color2.blue);
+           color3 = color2;
+           if (XAllocColor (dpy, cmap, &color3))
              {
-               XSetForeground (dpy, draw_gc, color.pixel);
+               XSetForeground (dpy, draw_gc, color3.pixel);
+               color2.pixel = color3.pixel;
                XFreeColors (dpy, cmap, &color.pixel, 1, 0);
              }
            color = color2;