X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fhelix.c;h=97de40dc7fb360ddd50a89b3ba5aba9659bb2a46;hb=0bd2eabab3e404c6769fe8f59b639275e960c415;hp=758c5557e1a7ef1d57cf44688603a088753576cc;hpb=f3e0240915ed9f9b3a61781f5c7002d587563fe0;p=xscreensaver diff --git a/hacks/helix.c b/hacks/helix.c index 758c5557..97de40dc 100644 --- a/hacks/helix.c +++ b/hacks/helix.c @@ -12,19 +12,23 @@ /* Algorithm from a Mac program by Chris Tate, written in 1988 or so. */ -/* 10-May-97: merged ellipse code by Dan Stromberg +/* 18-Sep-97: Johannes Keukelaar (johannes@nada.kth.se): Improved screen + * eraser. + * 10-May-97: merged ellipse code by Dan Stromberg * as found in xlockmore 4.03a10. * 1992: jwz created. */ #include #include "screenhack.h" +#include "erase.h" static double sins [360]; static double coss [360]; -static GC draw_gc, erase_gc; +static GC draw_gc; static unsigned int default_fg_pixel; +static int sleep_time; static void init_helix (Display *dpy, Window window) @@ -39,7 +43,6 @@ init_helix (Display *dpy, Window window) get_pixel_resource ("foreground", "Foreground", dpy, cmap); draw_gc = XCreateGC (dpy, window, GCForeground, &gcv); gcv.foreground = get_pixel_resource ("background", "Background", dpy, cmap); - erase_gc = XCreateGC (dpy, window, GCForeground, &gcv); for (i = 0; i < 360; i++) { @@ -250,7 +253,6 @@ random_trig (Display *dpy, Window window, XColor *color, Bool *got_color) static void random_helix_or_trig (Display *dpy, Window window) { - int i; Bool free_color = False; XColor color; int width, height; @@ -267,17 +269,10 @@ random_helix_or_trig (Display *dpy, Window window) random_trig(dpy, window, &color, &free_color); XSync (dpy, True); - sleep (5); + sleep ( sleep_time ); + + erase_full_window(dpy, window); - for (i = 0; i < height; i++) - { - int y = (random () % height); - XDrawLine (dpy, window, erase_gc, 0, y, width, y); - XFlush (dpy); - if ((i % 50) == 0) - usleep (10000); - } - XClearWindow (dpy, window); if (free_color) XFreeColors (dpy, cmap, &color.pixel, 1, 0); XSync (dpy, True); sleep (1); @@ -287,15 +282,21 @@ random_helix_or_trig (Display *dpy, Window window) char *progclass = "Helix"; char *defaults [] = { - "Helix.background: black", /* to placate SGI */ + ".background: black", + "*delay: 5", 0 }; -XrmOptionDescRec options [] = { { 0, } }; +XrmOptionDescRec options [] = { + { "-delay", ".delay", XrmoptionSepArg, 0 }, + { 0 }, +}; +int options_size = (sizeof (options) / sizeof (options[0])); void screenhack (Display *dpy, Window window) { + sleep_time = get_integer_resource("delay", "Integer"); init_helix (dpy, window); while (1) random_helix_or_trig (dpy, window);