1 /* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@lucid.com>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 #include "screenhack.h"
14 char *progclass = "XRoger";
23 XrmOptionDescRec options [] = {
24 { "-delay", ".delay", XrmoptionSepArg, 0 }
26 int options_size = (sizeof (options) / sizeof (options[0]));
29 extern void skull (Display *, Window, GC, GC, int, int, int, int);
33 screenhack (dpy, window)
43 int delay = get_integer_resource ("delay", "Integer");
44 XWindowAttributes xgwa;
45 XGetWindowAttributes (dpy, window, &xgwa);
47 gcv.foreground = get_pixel_resource ("background", "Background", dpy, cmap);
48 erase_gc = XCreateGC (dpy, window, GCForeground, &gcv);
49 fg = get_pixel_resource ("foreground", "Foreground", dpy, cmap);
50 if (fg == gcv.foreground)
51 fg = ((gcv.foreground == WhitePixel (dpy, DefaultScreen (dpy)))
52 ? BlackPixel (dpy, DefaultScreen (dpy))
53 : WhitePixel (dpy, DefaultScreen (dpy)));
55 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
56 color.pixel = gcv.foreground;
57 XQueryColor (dpy, cmap, &color);
60 int w, h, ww, hh, x, y;
62 XWindowAttributes xgwa;
63 XGetWindowAttributes (dpy, window, &xgwa);
67 ww = 100 + random () % (w - 100);
68 hh = 100 + random () % (h - 100);
73 x = random () % (w - ww);
74 y = random () % (h - hh);
75 XClearWindow (dpy, window);
76 skull (dpy, window, draw_gc, erase_gc, x, y, ww, hh);
78 start_time = time ((time_t *) 0);
82 while (start_time + delay > time ((time_t *) 0))
87 rgb_to_hsv (color2.red, color2.green, color2.blue, &h, &s, &v);
89 if (v >= 1.0) v = 1.0, delta = -delta;
90 if (v <= 0.7) v = 0.7, delta = -delta;
91 hsv_to_rgb (h, s, v, &color2.red, &color2.green, &color2.blue);
92 if (XAllocColor (dpy, cmap, &color2))
94 XSetForeground (dpy, draw_gc, color.pixel);
95 XFreeColors (dpy, cmap, &color.pixel, 1, 0);