X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Ferase.c;h=f3d6de8b49ebc8942972838a40b5fb846f8c7fe2;hb=de041722414a2e31c1c04caa10aaec9d6952e9b4;hp=c2c8de7b9da1520d9deed5873a910697cd02843f;hpb=a719ec12b8b2563112366a8ac3196816fd64d2c7;p=xscreensaver diff --git a/utils/erase.c b/utils/erase.c index c2c8de7b..f3d6de8b 100644 --- a/utils/erase.c +++ b/utils/erase.c @@ -348,7 +348,8 @@ fizzle (Display *dpy, Window window, GC gc, for( ix = 0, cx = 0; ix < width; ix += BX, cx++ ) { int xx = ix + (SKEWX(cx, cy) + x*((cx%(BX-1))+1))%BX; int yy = iy + (SKEWY(cx, cy) + y*((cy%(BY-1))+1))%BY; - XDrawPoint(dpy, window, gc, xx, yy); + if (xx < width && yy < height) + XDrawPoint(dpy, window, gc, xx, yy); } } } @@ -476,6 +477,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 +537,7 @@ static Eraser erasers[] = { fizzle, random_squares, spiral, + slide_lines, };