1 /* xscreensaver, Copyright (c) 1992, 1996, 1998, 2001
2 * Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
12 * 19971004: Johannes Keukelaar <johannes@nada.kth.se>: Use helix screen
16 #include "screenhack.h"
19 static GC draw_gc, erase_gc;
20 static unsigned int default_fg_pixel;
21 static int iterations, offset;
22 static Bool xsym, ysym;
23 static int sleep_time;
26 init_rorschach (Display *dpy, Window window)
30 XWindowAttributes xgwa;
31 XGetWindowAttributes (dpy, window, &xgwa);
33 gcv.foreground = default_fg_pixel =
34 get_pixel_resource ("foreground", "Foreground", dpy, cmap);
35 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
36 gcv.foreground = get_pixel_resource ("background", "Background", dpy, cmap);
37 erase_gc = XCreateGC (dpy, window, GCForeground, &gcv);
38 iterations = get_integer_resource ("iterations", "Integer");
39 offset = get_integer_resource ("offset", "Integer");
40 if (offset <= 0) offset = 3;
41 if (iterations < 10) iterations = 10;
42 xsym = get_boolean_resource ("xsymmetry", "Symmetry");
43 ysym = get_boolean_resource ("ysymmetry", "Symmetry");
47 hurm (Display *dpy, Window window)
50 XWindowAttributes xgwa;
51 int xlim, ylim, x, y, i, got_color = 0;
54 XClearWindow (dpy, window);
55 XGetWindowAttributes (dpy, window, &xgwa);
61 hsv_to_rgb (random()%360, 1.0, 1.0, &color.red, &color.green, &color.blue);
62 if ((!mono_p) && (got_color = XAllocColor (dpy, cmap, &color)))
63 XSetForeground (dpy, draw_gc, color.pixel);
65 XSetForeground (dpy, draw_gc, default_fg_pixel);
69 for (i = 0; i < iterations; i++)
72 x += ((random () % (1 + (offset << 1))) - offset);
73 y += ((random () % (1 + (offset << 1))) - offset);
79 points [j].x = xlim - x;
86 points [j].y = ylim - y;
91 points [j].x = xlim - x;
92 points [j].y = ylim - y;
95 XDrawPoints (dpy, window, draw_gc, points, j, CoordModeOrigin);
97 screenhack_handle_events (dpy);
101 erase_full_window(dpy, window);
103 XClearWindow (dpy, window);
104 if (got_color) XFreeColors (dpy, cmap, &color.pixel, 1, 0);
106 screenhack_handle_events (dpy);
111 char *progclass = "Rorschach";
113 char *defaults [] = {
114 ".background: black",
115 ".foreground: white",
124 XrmOptionDescRec options [] = {
125 { "-iterations", ".iterations", XrmoptionSepArg, 0 },
126 { "-offset", ".offset", XrmoptionSepArg, 0 },
127 { "-xsymmetry", ".xsymmetry", XrmoptionNoArg, "true" },
128 { "-ysymmetry", ".ysymmetry", XrmoptionNoArg, "true" },
129 { "-no-xsymmetry", ".xsymmetry", XrmoptionNoArg, "false" },
130 { "-no-ysymmetry", ".ysymmetry", XrmoptionNoArg, "false" },
131 { "-erase-speed", ".eraseSpeed", XrmoptionSepArg, 0 },
132 { "-delay", ".delay", XrmoptionSepArg, 0 },
137 screenhack (Display *dpy, Window window)
139 sleep_time = get_integer_resource("delay", "Integer");
140 init_rorschach (dpy, window);