1 /* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@jwz.org>
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 },
28 extern void skull (Display *, Window, GC, GC, int, int, int, int);
31 screenhack (dpy, window)
40 XColor color, color2, color3;
41 int delay = get_integer_resource ("delay", "Integer");
42 XWindowAttributes xgwa;
43 XGetWindowAttributes (dpy, window, &xgwa);
45 gcv.foreground = get_pixel_resource ("background", "Background", dpy, cmap);
46 erase_gc = XCreateGC (dpy, window, GCForeground, &gcv);
47 fg = get_pixel_resource ("foreground", "Foreground", dpy, cmap);
48 if (fg == gcv.foreground)
49 fg = ((gcv.foreground == WhitePixel (dpy, DefaultScreen (dpy)))
50 ? BlackPixel (dpy, DefaultScreen (dpy))
51 : WhitePixel (dpy, DefaultScreen (dpy)));
53 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
54 color.pixel = gcv.foreground;
55 XQueryColor (dpy, cmap, &color);
58 int w, h, ww, hh, x, y;
60 XGetWindowAttributes (dpy, window, &xgwa);
64 ww = 100 + random () % (w - 100);
65 hh = 100 + random () % (h - 100);
70 x = random () % (w - ww);
71 y = random () % (h - hh);
72 XClearWindow (dpy, window);
75 skull (dpy, window, draw_gc, erase_gc, x, y, ww, hh);
77 screenhack_handle_events (dpy);
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.6) V = 0.7, delta = -delta;
91 hsv_to_rgb (H, S, V, &color2.red, &color2.green, &color2.blue);
93 if (XAllocColor (dpy, cmap, &color3))
95 XSetForeground (dpy, draw_gc, color3.pixel);
96 color2.pixel = color3.pixel;
97 XFreeColors (dpy, cmap, &color.pixel, 1, 0);