X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fhelix.c;h=7ca03da7760377aed93d87006bac39bb71ae977d;hb=96a411663168b0ba5432b407a83be55f3df0c802;hp=c2d81fa22dfd6785931160d3c8e03ed688e12135;hpb=ce3185de9d9705e259f2b60dd4b5509007fa17d4;p=xscreensaver diff --git a/hacks/helix.c b/hacks/helix.c index c2d81fa2..7ca03da7 100644 --- a/hacks/helix.c +++ b/hacks/helix.c @@ -19,6 +19,9 @@ * 1992: jwz created. */ +/* 25 April 2002: Matthew Strait added +-subdelay option so the drawing process can be watched */ + #include #include "screenhack.h" #include "erase.h" @@ -29,6 +32,7 @@ static double coss [360]; static GC draw_gc; static unsigned int default_fg_pixel; static int sleep_time; +static int subdelay; static void init_helix (Display *dpy, Window window) @@ -99,9 +103,12 @@ helix (Display *dpy, Window window, XDrawLine (dpy, window, draw_gc, x1, y1, x2, y2); x2 = xmid + (((double) radius2) * sins [pmod ((angle * factor3), 360)]); y2 = ymid + (((double) radius1) * coss [pmod ((angle * factor4), 360)]); - XDrawLine (dpy, window, draw_gc, x1, y1, x2, y2); angle += d_angle; + + /* if we sleep every time, it's too slow */ + if(subdelay && i%16 == 0) usleep(subdelay); + XFlush (dpy); } } @@ -139,6 +146,12 @@ trig (Display *dpy, Window window, if (tmp == 0) /* Do not want it getting stuck... */ tmp = 1; /* Would not need if floating point */ d_angle += dir * tmp; + + /* this draws faster, so we sleep somewhat more often */ + if(subdelay && d_angle%4 == 0) usleep(subdelay); + + /* without this, the subdelay effect is lost */ + XFlush (dpy); } } @@ -268,13 +281,16 @@ random_helix_or_trig (Display *dpy, Window window) else random_trig(dpy, window, &color, &free_color); - XSync (dpy, True); + XSync (dpy, False); + screenhack_handle_events (dpy); sleep ( sleep_time ); + screenhack_handle_events (dpy); erase_full_window(dpy, window); if (free_color) XFreeColors (dpy, cmap, &color.pixel, 1, 0); - XSync (dpy, True); + XSync (dpy, False); + screenhack_handle_events (dpy); sleep (1); } @@ -284,12 +300,14 @@ char *progclass = "Helix"; char *defaults [] = { ".background: black", "*delay: 5", + "*subdelay: 0", 0 }; XrmOptionDescRec options [] = { { "-delay", ".delay", XrmoptionSepArg, 0 }, - { 0 }, + { "-subdelay", ".subdelay", XrmoptionSepArg, 0 }, + { 0, 0, 0, 0 }, }; int options_size = (sizeof (options) / sizeof (options[0])); @@ -297,6 +315,7 @@ void screenhack (Display *dpy, Window window) { sleep_time = get_integer_resource("delay", "Integer"); + subdelay = get_integer_resource("subdelay", "Integer"); init_helix (dpy, window); while (1) random_helix_or_trig (dpy, window);