1 /* nerverot, nervous rotation of random thingies, v1.2
2 * by Dan Bornstein, danfuzz@milk.com
3 * Copyright (c) 2000 Dan Bornstein.
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation. No representations are made about the suitability of this
10 * software for any purpose. It is provided "as is" without express or
13 * The goal of this screensaver is to be interesting and compelling to
14 * watch, yet induce a state of nervous edginess in the viewer.
16 * See the included man page for more details.
20 #include "screenhack.h"
24 /* random float in the range (-1..1) */
25 #define RAND_FLOAT_PM1 \
26 (((FLOAT) ((random() >> 8) & 0xffff)) / ((FLOAT) 0x10000) * 2 - 1)
28 /* random float in the range (0..1) */
29 #define RAND_FLOAT_01 \
30 (((FLOAT) ((random() >> 8) & 0xffff)) / ((FLOAT) 0x10000))
34 /* parameters that are user configurable */
37 static int requestedBlotCount;
39 /* delay (usec) between iterations */
42 /* variability of xoff/yoff per iteration (0..1) */
43 static FLOAT nervousness;
45 /* max nervousness radius (0..1) */
46 static FLOAT maxNerveRadius;
48 /* chance per iteration that an event will happen */
49 static FLOAT eventChance;
51 /* fraction (0..1) towards rotation target or scale target to move each
55 /* min and max scale for drawing, as fraction of baseScale */
56 static FLOAT minScale;
57 static FLOAT maxScale;
59 /* min and max radius of blot drawing */
63 /* the number of colors to use */
64 static int colorCount;
69 /* whether or not to do double-buffering */
70 static Bool doubleBuffer;
74 /* non-user-modifiable immutable definitions */
76 /* base scale factor for drawing, calculated as
77 * max(screenWidth,screenHeight) */
80 /* width and height of the window */
81 static int windowWidth;
82 static int windowHeight;
84 /* center position of the window */
88 static Display *display; /* the display to draw on */
89 static Window window; /* the window to draw on */
90 static Drawable drawable; /* the thing to directly draw on */
91 static GC *gcs; /* array of gcs, one per color used */
95 /* structure of the model */
97 /* each point-like thingy to draw is represented as a blot */
100 FLOAT x; /* 3d x position (-1..1) */
101 FLOAT y; /* 3d y position (-1..1) */
102 FLOAT z; /* 3d z position (-1..1) */
103 FLOAT xoff[3][3]; /* display x offset per drawn point (-1..1) */
104 FLOAT yoff[3][3]; /* display x offset per drawn point (-1..1) */
107 /* each drawn line is represented as a LineSegment */
108 typedef struct linesegment_s
117 /* array of the blots in the model */
118 static Blot *blots = NULL;
119 static int blotCount;
121 /* each blot draws as a simple 2d shape with each coordinate as an int
122 * in the range (-1..1); this is the base shape */
123 static XPoint blotShape[] = { { 0, 0}, { 1, 0}, { 1, 1},
124 { 0, 1}, {-1, 1}, {-1, 0},
125 {-1,-1}, { 0,-1}, { 1,-1} };
126 static int blotShapeCount = sizeof (blotShape) / sizeof (XPoint);
128 /* two arrays of line segments; one for the ones to erase, and one for the
131 static LineSegment *segsToDraw = NULL;
132 static LineSegment *segsToErase = NULL;
134 /* current rotation values per axis, scale factor, and light position */
138 static FLOAT curScale;
143 /* target rotation values per axis, scale factor, and light position */
144 static FLOAT xRotTarget;
145 static FLOAT yRotTarget;
146 static FLOAT zRotTarget;
147 static FLOAT scaleTarget;
148 static FLOAT lightXTarget;
149 static FLOAT lightYTarget;
150 static FLOAT lightZTarget;
152 /* current absolute offsets from the center */
153 static int centerXOff = 0;
154 static int centerYOff = 0;
156 /* iterations until the model changes */
157 static int itersTillNext;
165 /* initialize a blot with the given coordinates and random display offsets */
166 static void initBlot (Blot *b, FLOAT x, FLOAT y, FLOAT z)
174 for (i = 0; i < 3; i++)
176 for (j = 0; j < 3; j++)
178 b->xoff[i][j] = RAND_FLOAT_PM1;
179 b->yoff[i][j] = RAND_FLOAT_PM1;
184 /* scale the blots to have a max distance of 1 from the center */
185 static void scaleBlotsToRadius1 (void)
190 for (n = 0; n < blotCount; n++)
193 blots[n].x * blots[n].x +
194 blots[n].y * blots[n].y +
195 blots[n].z * blots[n].z;
196 if (distSquare > max)
209 for (n = 0; n < blotCount; n++)
217 /* randomly reorder the blots */
218 static void randomlyReorderBlots (void)
222 for (n = 0; n < blotCount; n++)
224 int m = RAND_FLOAT_01 * (blotCount - n) + n;
225 Blot tmpBlot = blots[n];
231 /* set up the initial array of blots to be a at the edge of a sphere */
232 static void setupBlotsSphere (void)
236 blotCount = requestedBlotCount;
237 blots = calloc (sizeof (Blot), blotCount);
239 for (n = 0; n < blotCount; n++)
241 /* pick a spot, but reject if its radius is < 0.2 or > 1 to
242 * avoid scaling problems */
243 FLOAT x, y, z, radius;
251 radius = sqrt (x * x + y * y + z * z);
252 if ((radius >= 0.2) && (radius <= 1.0))
262 initBlot (&blots[n], x, y, z);
268 /* set up the initial array of blots to be a simple cube */
269 static void setupBlotsCube (void)
273 /* derive blotsPerEdge from blotCount, but then do the reverse
274 * since roundoff may have changed blotCount */
275 int blotsPerEdge = ((requestedBlotCount - 8) / 12) + 2;
278 if (blotsPerEdge < 2)
283 distBetween = 2.0 / (blotsPerEdge - 1.0);
285 blotCount = 8 + (blotsPerEdge - 2) * 12;
286 blots = calloc (sizeof (Blot), blotCount);
289 /* define the corners */
290 for (i = -1; i < 2; i += 2)
292 for (j = -1; j < 2; j += 2)
294 for (k = -1; k < 2; k += 2)
296 initBlot (&blots[n], i, j, k);
302 /* define the edges */
303 for (i = 1; i < (blotsPerEdge - 1); i++)
305 FLOAT varEdge = distBetween * i - 1;
306 initBlot (&blots[n++], varEdge, -1, -1);
307 initBlot (&blots[n++], varEdge, 1, -1);
308 initBlot (&blots[n++], varEdge, -1, 1);
309 initBlot (&blots[n++], varEdge, 1, 1);
310 initBlot (&blots[n++], -1, varEdge, -1);
311 initBlot (&blots[n++], 1, varEdge, -1);
312 initBlot (&blots[n++], -1, varEdge, 1);
313 initBlot (&blots[n++], 1, varEdge, 1);
314 initBlot (&blots[n++], -1, -1, varEdge);
315 initBlot (&blots[n++], 1, -1, varEdge);
316 initBlot (&blots[n++], -1, 1, varEdge);
317 initBlot (&blots[n++], 1, 1, varEdge);
320 scaleBlotsToRadius1 ();
321 randomlyReorderBlots ();
326 /* set up the initial array of blots to be a cylinder */
327 static void setupBlotsCylinder (void)
331 /* derive blotsPerEdge from blotCount, but then do the reverse
332 * since roundoff may have changed blotCount */
333 int blotsPerEdge = requestedBlotCount / 32;
336 if (blotsPerEdge < 2)
341 distBetween = 2.0 / (blotsPerEdge - 1);
343 blotCount = blotsPerEdge * 32;
344 blots = calloc (sizeof (Blot), blotCount);
347 /* define the edges */
348 for (i = 0; i < 32; i++)
350 FLOAT x = sin (2 * M_PI / 32 * i);
351 FLOAT y = cos (2 * M_PI / 32 * i);
352 for (j = 0; j < blotsPerEdge; j++)
354 initBlot (&blots[n], x, y, j * distBetween - 1);
359 scaleBlotsToRadius1 ();
360 randomlyReorderBlots ();
365 /* set up the initial array of blots to be a squiggle */
366 static void setupBlotsSquiggle (void)
368 FLOAT x, y, z, xv, yv, zv, len;
371 blotCount = requestedBlotCount;
372 blots = calloc (sizeof (Blot), blotCount);
381 len = sqrt (xv * xv + yv * yv + zv * zv);
386 for (n = 0; n < blotCount; n++)
388 FLOAT newx, newy, newz;
389 initBlot (&blots[n], x, y, z);
393 xv += RAND_FLOAT_PM1 * 0.1;
394 yv += RAND_FLOAT_PM1 * 0.1;
395 zv += RAND_FLOAT_PM1 * 0.1;
396 len = sqrt (xv * xv + yv * yv + zv * zv);
405 if ( (newx >= -1) && (newx <= 1)
406 && (newy >= -1) && (newy <= 1)
407 && (newz >= -1) && (newz <= 1))
418 scaleBlotsToRadius1 ();
419 randomlyReorderBlots ();
424 /* set up the initial array of blots to be near the corners of a
425 * cube, distributed slightly */
426 static void setupBlotsCubeCorners (void)
430 blotCount = requestedBlotCount;
431 blots = calloc (sizeof (Blot), blotCount);
433 for (n = 0; n < blotCount; n++)
435 FLOAT x = rint (RAND_FLOAT_01) * 2 - 1;
436 FLOAT y = rint (RAND_FLOAT_01) * 2 - 1;
437 FLOAT z = rint (RAND_FLOAT_01) * 2 - 1;
439 x += RAND_FLOAT_PM1 * 0.3;
440 y += RAND_FLOAT_PM1 * 0.3;
441 z += RAND_FLOAT_PM1 * 0.3;
443 initBlot (&blots[n], x, y, z);
446 scaleBlotsToRadius1 ();
451 /* forward declaration for recursive use immediately below */
452 static void setupBlots (void);
454 /* set up the blots to be two of the other choices, placed next to
456 static void setupBlotsDuo (void)
458 int origRequest = requestedBlotCount;
459 FLOAT tx, ty, tz, radius;
460 Blot *blots1, *blots2;
464 if (requestedBlotCount < 15)
466 /* special case bottom-out */
474 radius = sqrt (tx * tx + ty * ty + tz * tz);
479 /* recursive call to setup set 1 */
480 requestedBlotCount = origRequest / 2;
483 if (blotCount >= origRequest)
485 /* return immediately if this satisfies the original count request */
494 /* translate to new position */
495 for (n = 0; n < count1; n++)
502 /* recursive call to setup set 2 */
503 requestedBlotCount = origRequest - count1;
508 /* translate to new position */
509 for (n = 0; n < count2; n++)
516 /* combine the two arrays */
517 blotCount = count1 + count2;
518 blots = calloc (sizeof (Blot), blotCount);
519 memcpy (&blots[0], blots1, sizeof (Blot) * count1);
520 memcpy (&blots[count1], blots2, sizeof (Blot) * count2);
524 scaleBlotsToRadius1 ();
525 randomlyReorderBlots ();
527 /* restore the original requested count, for future iterations */
528 requestedBlotCount = origRequest;
533 /* free the blots, in preparation for a new shape */
534 static void freeBlots (void)
542 if (segsToErase != NULL)
548 if (segsToDraw != NULL)
557 /* set up the initial arrays of blots */
558 static void setupBlots (void)
560 int which = RAND_FLOAT_01 * 7;
573 setupBlotsCylinder ();
576 setupBlotsSquiggle ();
579 setupBlotsCubeCorners ();
590 /* set up the segments arrays */
591 static void setupSegs (void)
593 /* there are blotShapeCount - 1 line segments per blot */
594 segCount = blotCount * (blotShapeCount - 1);
595 segsToErase = calloc (sizeof (LineSegment), segCount);
596 segsToDraw = calloc (sizeof (LineSegment), segCount);
598 /* erase the world */
599 XFillRectangle (display, drawable, gcs[0], 0, 0,
600 windowWidth, windowHeight);
609 /* set up the colormap */
610 static void setupColormap (XWindowAttributes *xgwa)
614 XColor *colors = (XColor *) calloc (sizeof (XColor), colorCount + 1);
616 unsigned short r, g, b;
618 double s1, s2, v1, v2;
620 r = RAND_FLOAT_01 * 0x10000;
621 g = RAND_FLOAT_01 * 0x10000;
622 b = RAND_FLOAT_01 * 0x10000;
623 rgb_to_hsv (r, g, b, &h1, &s1, &v1);
627 r = RAND_FLOAT_01 * 0x10000;
628 g = RAND_FLOAT_01 * 0x10000;
629 b = RAND_FLOAT_01 * 0x10000;
630 rgb_to_hsv (r, g, b, &h2, &s2, &v2);
634 colors[0].pixel = get_pixel_resource ("background", "Background",
635 display, xgwa->colormap);
637 make_color_ramp (display, xgwa->colormap, h1, s1, v1, h2, s2, v2,
638 colors + 1, &colorCount, False, True, False);
642 fprintf (stderr, "%s: couldn't allocate any colors\n", progname);
646 gcs = (GC *) calloc (sizeof (GC), colorCount + 1);
648 for (n = 0; n <= colorCount; n++)
650 gcv.foreground = colors[n].pixel;
651 gcv.line_width = lineWidth;
652 gcs[n] = XCreateGC (display, window, GCForeground | GCLineWidth, &gcv);
661 * overall setup stuff
664 /* set up the system */
665 static void setup (void)
667 XWindowAttributes xgwa;
669 XGetWindowAttributes (display, window, &xgwa);
671 windowWidth = xgwa.width;
672 windowHeight = xgwa.height;
673 centerX = windowWidth / 2;
674 centerY = windowHeight / 2;
675 baseScale = (xgwa.height < xgwa.width) ? xgwa.height : xgwa.width;
679 drawable = XCreatePixmap (display, window, xgwa.width, xgwa.height,
687 setupColormap (&xgwa);
691 /* set up the initial rotation, scale, and light values as random, but
692 * with the targets equal to where it is */
693 xRot = xRotTarget = RAND_FLOAT_01 * M_PI;
694 yRot = yRotTarget = RAND_FLOAT_01 * M_PI;
695 zRot = zRotTarget = RAND_FLOAT_01 * M_PI;
696 curScale = scaleTarget = RAND_FLOAT_01 * (maxScale - minScale) + minScale;
697 lightX = lightXTarget = RAND_FLOAT_PM1;
698 lightY = lightYTarget = RAND_FLOAT_PM1;
699 lightZ = lightZTarget = RAND_FLOAT_PM1;
701 itersTillNext = RAND_FLOAT_01 * 1234;
710 /* "render" the blots into segsToDraw, with the current rotation factors */
711 static void renderSegs (void)
716 /* rotation factors */
717 FLOAT sinX = sin (xRot);
718 FLOAT cosX = cos (xRot);
719 FLOAT sinY = sin (yRot);
720 FLOAT cosY = cos (yRot);
721 FLOAT sinZ = sin (zRot);
722 FLOAT cosZ = cos (zRot);
724 for (n = 0; n < blotCount; n++)
734 FLOAT x1 = blots[n].x;
735 FLOAT y1 = blots[n].y;
736 FLOAT z1 = blots[n].z;
739 /* rotate on z axis */
740 x2 = x1 * cosZ - y1 * sinZ;
741 y2 = x1 * sinZ + y1 * cosZ;
744 /* rotate on x axis */
745 y1 = y2 * cosX - z2 * sinX;
746 z1 = y2 * sinX + z2 * cosX;
749 /* rotate on y axis */
750 z2 = z1 * cosY - x1 * sinY;
751 x2 = z1 * sinY + x1 * cosY;
754 /* the color to draw is based on the distance from the light of
755 * the post-rotation blot */
759 color = 1 + (x1 * x1 + y1 * y1 + z1 * z1) / 4 * colorCount;
760 if (color > colorCount)
765 /* set up the base screen coordinates for drawing */
766 baseX = x2 / 2 * baseScale * curScale + centerX + centerXOff;
767 baseY = y2 / 2 * baseScale * curScale + centerY + centerYOff;
769 radius = (z2 + 1) / 2 * (maxRadius - minRadius) + minRadius;
771 for (i = 0; i < 3; i++)
773 for (j = 0; j < 3; j++)
776 ((i - 1) + (b->xoff[i][j] * maxNerveRadius)) * radius;
778 ((j - 1) + (b->yoff[i][j] * maxNerveRadius)) * radius;
782 for (i = 1; i < blotShapeCount; i++)
784 segsToDraw[m].gc = gcs[color];
785 segsToDraw[m].x1 = x[blotShape[i-1].x + 1][blotShape[i-1].y + 1];
786 segsToDraw[m].y1 = y[blotShape[i-1].x + 1][blotShape[i-1].y + 1];
787 segsToDraw[m].x2 = x[blotShape[i].x + 1][blotShape[i].y + 1];
788 segsToDraw[m].y2 = y[blotShape[i].x + 1][blotShape[i].y + 1];
794 /* update blots, adjusting the offsets and rotation factors. */
795 static void updateWithFeeling (void)
799 /* pick a new model if the time is right */
801 if (itersTillNext < 0)
803 itersTillNext = RAND_FLOAT_01 * 1234;
809 /* update the rotation factors by moving them a bit toward the targets */
810 xRot = xRot + (xRotTarget - xRot) * iterAmt;
811 yRot = yRot + (yRotTarget - yRot) * iterAmt;
812 zRot = zRot + (zRotTarget - zRot) * iterAmt;
814 /* similarly the scale factor */
815 curScale = curScale + (scaleTarget - curScale) * iterAmt;
817 /* and similarly the light position */
818 lightX = lightX + (lightXTarget - lightX) * iterAmt;
819 lightY = lightY + (lightYTarget - lightY) * iterAmt;
820 lightZ = lightZ + (lightZTarget - lightZ) * iterAmt;
822 /* for each blot... */
823 for (n = 0; n < blotCount; n++)
825 /* add a bit of random jitter to xoff/yoff */
826 for (i = 0; i < 3; i++)
828 for (j = 0; j < 3; j++)
832 newOff = blots[n].xoff[i][j] + RAND_FLOAT_PM1 * nervousness;
833 if (newOff < -1) newOff = -(newOff + 1) - 1;
834 else if (newOff > 1) newOff = -(newOff - 1) + 1;
835 blots[n].xoff[i][j] = newOff;
837 newOff = blots[n].yoff[i][j] + RAND_FLOAT_PM1 * nervousness;
838 if (newOff < -1) newOff = -(newOff + 1) - 1;
839 else if (newOff > 1) newOff = -(newOff - 1) + 1;
840 blots[n].yoff[i][j] = newOff;
845 /* depending on random chance, update one or more factors */
846 if (RAND_FLOAT_01 <= eventChance)
848 int which = RAND_FLOAT_01 * 14;
853 xRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
858 yRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
863 zRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
868 xRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
869 yRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
874 xRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
875 zRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
880 yRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
881 zRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
886 xRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
887 yRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
888 zRotTarget = RAND_FLOAT_PM1 * M_PI * 2;
893 centerXOff = RAND_FLOAT_PM1 * maxRadius;
898 centerYOff = RAND_FLOAT_PM1 * maxRadius;
903 centerXOff = RAND_FLOAT_PM1 * maxRadius;
904 centerYOff = RAND_FLOAT_PM1 * maxRadius;
910 RAND_FLOAT_01 * (maxScale - minScale) + minScale;
916 RAND_FLOAT_01 * (maxScale - minScale) + minScale;
921 lightX = RAND_FLOAT_PM1;
922 lightY = RAND_FLOAT_PM1;
923 lightZ = RAND_FLOAT_PM1;
928 lightXTarget = RAND_FLOAT_PM1;
929 lightYTarget = RAND_FLOAT_PM1;
930 lightZTarget = RAND_FLOAT_PM1;
937 /* erase segsToErase and draw segsToDraw */
938 static void eraseAndDraw (void)
942 for (n = 0; n < segCount; n++)
944 LineSegment *seg = &segsToErase[n];
945 XDrawLine (display, drawable, gcs[0],
946 seg->x1, seg->y1, seg->x2, seg->y2);
947 seg = &segsToDraw[n];
948 XDrawLine (display, drawable, seg->gc,
949 seg->x1, seg->y1, seg->x2, seg->y2);
954 XCopyArea (display, drawable, window, gcs[0], 0, 0,
955 windowWidth, windowHeight, 0, 0);
959 /* do one iteration */
960 static void oneIteration (void)
962 /* switch segsToErase and segsToDraw */
963 LineSegment *temp = segsToDraw;
964 segsToDraw = segsToErase;
967 /* update the model */
968 updateWithFeeling ();
970 /* render new segments */
973 /* erase old segments and draw new ones */
977 char *progclass = "NerveRot";
979 char *defaults [] = {
980 ".background: black",
981 ".foreground: white",
985 "*doubleBuffer: false",
993 "*maxNerveRadius: 0.7",
998 XrmOptionDescRec options [] = {
999 { "-count", ".count", XrmoptionSepArg, 0 },
1000 { "-colors", ".colors", XrmoptionSepArg, 0 },
1001 { "-delay", ".delay", XrmoptionSepArg, 0 },
1002 { "-db", ".doubleBuffer", XrmoptionNoArg, "true" },
1003 { "-no-db", ".doubleBuffer", XrmoptionNoArg, "false" },
1004 { "-event-chance", ".eventChance", XrmoptionSepArg, 0 },
1005 { "-iter-amt", ".iterAmt", XrmoptionSepArg, 0 },
1006 { "-line-width", ".lineWidth", XrmoptionSepArg, 0 },
1007 { "-min-scale", ".minScale", XrmoptionSepArg, 0 },
1008 { "-max-scale", ".maxScale", XrmoptionSepArg, 0 },
1009 { "-min-radius", ".minRadius", XrmoptionSepArg, 0 },
1010 { "-max-radius", ".maxRadius", XrmoptionSepArg, 0 },
1011 { "-max-nerve-radius", ".maxNerveRadius", XrmoptionSepArg, 0 },
1012 { "-nervousness", ".nervousness", XrmoptionSepArg, 0 },
1016 /* initialize the user-specifiable params */
1017 static void initParams (void)
1021 delay = get_integer_resource ("delay", "Delay");
1024 fprintf (stderr, "error: delay must be at least 0\n");
1028 doubleBuffer = get_boolean_resource ("doubleBuffer", "Boolean");
1030 requestedBlotCount = get_integer_resource ("count", "Count");
1031 if (requestedBlotCount <= 0)
1033 fprintf (stderr, "error: count must be at least 0\n");
1037 colorCount = get_integer_resource ("colors", "Colors");
1038 if (colorCount <= 0)
1040 fprintf (stderr, "error: colors must be at least 1\n");
1044 lineWidth = get_integer_resource ("lineWidth", "LineWidth");
1047 fprintf (stderr, "error: line width must be at least 0\n");
1051 nervousness = get_float_resource ("nervousness", "Float");
1052 if ((nervousness < 0) || (nervousness > 1))
1054 fprintf (stderr, "error: nervousness must be in the range 0..1\n");
1058 maxNerveRadius = get_float_resource ("maxNerveRadius", "Float");
1059 if ((maxNerveRadius < 0) || (maxNerveRadius > 1))
1061 fprintf (stderr, "error: maxNerveRadius must be in the range 0..1\n");
1065 eventChance = get_float_resource ("eventChance", "Float");
1066 if ((eventChance < 0) || (eventChance > 1))
1068 fprintf (stderr, "error: eventChance must be in the range 0..1\n");
1072 iterAmt = get_float_resource ("iterAmt", "Float");
1073 if ((iterAmt < 0) || (iterAmt > 1))
1075 fprintf (stderr, "error: iterAmt must be in the range 0..1\n");
1079 minScale = get_float_resource ("minScale", "Float");
1080 if ((minScale < 0) || (minScale > 10))
1082 fprintf (stderr, "error: minScale must be in the range 0..10\n");
1086 maxScale = get_float_resource ("maxScale", "Float");
1087 if ((maxScale < 0) || (maxScale > 10))
1089 fprintf (stderr, "error: maxScale must be in the range 0..10\n");
1093 if (maxScale < minScale)
1095 fprintf (stderr, "error: maxScale must be >= minScale\n");
1099 minRadius = get_integer_resource ("minRadius", "Integer");
1100 if ((minRadius < 1) || (minRadius > 100))
1102 fprintf (stderr, "error: minRadius must be in the range 1..100\n");
1106 maxRadius = get_integer_resource ("maxRadius", "Integer");
1107 if ((maxRadius < 1) || (maxRadius > 100))
1109 fprintf (stderr, "error: maxRadius must be in the range 1..100\n");
1113 if (maxRadius < minRadius)
1115 fprintf (stderr, "error: maxRadius must be >= minRadius\n");
1126 void screenhack (Display *dpy, Window win)
1134 /* make a valid set to erase at first */
1141 screenhack_handle_events (dpy);