
gnu.app.displayhack.eraser.SlideLines Maven / Gradle / Ivy
Show all versions of escher Show documentation
package gnu.app.displayhack.eraser;
import gnu.x11.Window;
import gnu.app.displayhack.DisplayHack;
/**
* Erase by sliding lines.
*
* Modified from slide_lines
of erase.c
in xscreensaver by Torbjorn
* Andersson .
*
* Trivially added erase in y-direction support.
*/
public class SlideLines extends Eraser {
/**
* TODO
* 1. accelerating slide?
* 2. slide in any directions?
*/
public static final int SLICE = 100;
public static final int DELAY = 200;
public SlideLines () { super ("slide-lines"); }
public void erase (DisplayHack hack) {
// no useless notify events
hack.eraser_gc.set_graphics_exposures (false);
if (hack.random.nextBoolean ())
horizontal_erase (hack);
else
vertical_erase (hack);
hack.sleep (hack.delay/2); // before next screen
}
/**
* Erase in x-direction. Exactly the same as {@link
* #vertical_erase(DisplayHack)} with x and y-related swapped.
*/
public void horizontal_erase (DisplayHack hack) {
Window window = hack.window;
int dx = Math.max (1, window.width / DELAY * hack.eraser_delta);
int dy = Math.max (1, window.height / SLICE * hack.eraser_delta);
for (int x=0; x