http://ftp.x.org/contrib/applications/xscreensaver-3.23.tar.gz
[xscreensaver] / hacks / braid.c
index e6d0cf30acb4fd849cb0f102eff4f80775149d98..9d9c4e5fd37d7191520da055279ae13f4e204f3e 100644 (file)
@@ -21,7 +21,7 @@ static const char sccsid[] = "@(#)braid.c     4.00 97/01/01 xlockmore";
  * other special, indirect and consequential damages.
  *
  * Revision History:
- * 10-May-97: jwz@netscape.com: turned into a standalone program.
+ * 10-May-97: jwz@jwz.org: turned into a standalone program.
  * 01-Sep-95: color knotted components differently, J. Neil.
  * 29-Aug-95: Written.  John Neil <neil@math.idbsu.edu>
  */
@@ -32,11 +32,13 @@ static const char sccsid[] = "@(#)braid.c   4.00 97/01/01 xlockmore";
 # define HACK_DRAW                                     draw_braid
 # define braid_opts                                    xlockmore_opts
 # define DEFAULTS      "*count:                15    \n"                       \
+                                       "*size:            -7     \n"                   \
                                        "*cycles:               100   \n"                       \
                                        "*delay:                1000  \n"                       \
                                        "*ncolors:              64    \n"
 # define UNIFORM_COLORS
 # include "xlockmore.h"                                /* from the xscreensaver distribution */
+# include "erase.h"
 #else  /* !STANDALONE */
 # include "xlock.h"                                    /* from the xlockmore distribution */
 #endif /* !STANDALONE */
@@ -164,7 +166,6 @@ init_braid(ModeInfo * mi)
 
        /* jwz: go in the other direction sometimes. */
        braid->color_direction = ((LRAND() & 1) ? 1 : -1);
-
        XClearWindow(display, MI_WINDOW(mi));
 
        min_length = (braid->center_x > braid->center_y) ?
@@ -236,6 +237,21 @@ init_braid(ModeInfo * mi)
                }
        } while (count > 0);
 
+       {
+         int line_width = MI_SIZE(mi);
+         if (line_width == 0)
+               line_width = -8;
+         if (line_width < 0)
+               line_width = NRAND(-line_width)+1;
+         if (line_width == 1)
+               line_width = 0;
+         XSetLineAttributes(MI_DISPLAY(mi), MI_GC(mi), line_width,
+                                                LineSolid,
+                                                (line_width <= 3 ? CapButt : CapRound),
+                                                JoinMiter);
+       }
+
+
        for (i = 0; i < braid->nstrands; i++)
                if (!(braid->components[i] & 1))
                        braid->components[i] *= -1;
@@ -394,8 +410,12 @@ draw_braid(ModeInfo * mi)
                }
        }
 
-       if (++braid->age > MI_CYCLES(mi))
-               init_braid(mi);
+       if (++braid->age > MI_CYCLES(mi)) {
+#ifdef STANDALONE
+         erase_full_window(MI_DISPLAY(mi), MI_WINDOW(mi));
+#endif
+         init_braid(mi);
+       }
 }
 
 void