X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=utils%2Ferase.c;h=851b5b490dfce2006d43377b00173e249bb0d3c9;hp=c2c8de7b9da1520d9deed5873a910697cd02843f;hb=0316d74da7982288abddd34e7a62698eb7f79965;hpb=06e9a7886a77cad92f9ddbc169d6d199a4d8b76d diff --git a/utils/erase.c b/utils/erase.c index c2c8de7b..851b5b49 100644 --- a/utils/erase.c +++ b/utils/erase.c @@ -476,6 +476,54 @@ random_squares(Display * dpy, Window window, GC gc, free(squares); } +/* I first saw something like this, albeit in reverse, in an early Tetris + implementation for the Mac. + -- Torbjörn Andersson + */ + +static void +slide_lines (Display * dpy, Window window, GC gc, int width, int height, + int delay, int granularity) +{ + int slide_old_x, slide_new_x, clear_x; + int x, y, dx, dy; + + /* This might need some tuning. The idea is to get sensible values no + matter what the size of the window. + + Everything moves at constant speed. Should it accelerate instead? */ + + granularity *= 2; + + dy = MAX (1, height / granularity); + dx = MAX (1, width / 100); + + for (x = 0; x < width; x += dx) + { + for (y = 0; y < height; y += dy) + { + if ((y / dy) & 1) + { + slide_old_x = x; + slide_new_x = x + dx; + clear_x = x; + } + else + { + slide_old_x = dx; + slide_new_x = 0; + clear_x = width - x - dx; + } + + XCopyArea (dpy, window, window, gc, slide_old_x, y, width - x - dx, + dy, slide_new_x, y); + XClearArea (dpy, window, clear_x, y, dx, dy, False); + } + + XSync(dpy, False); + usleep(delay * 3); + } +} static Eraser erasers[] = { random_lines, @@ -488,6 +536,7 @@ static Eraser erasers[] = { fizzle, random_squares, spiral, + slide_lines, };