
gnu.app.displayhack.Munch Maven / Gradle / Ivy
Show all versions of escher Show documentation
package gnu.app.displayhack;
/**
* Munching squares. It performs the munching squares hack until killed. It
* picks square size, position, and gravity randomly. It consists of drawing
* Y = X XOR T for a range of X and T over and over until all the possible
* combinations of X and T have come up. It was reportedly discovered by
* Jackson Wright in 1962 and took 5 instructions of PDP-6 code.
*
* Modified from munch.c
in xscreensaver by Tim Showalter
* . Cleaned up to used eraser.
*
* @see
* jargon file
*
* @see
* hakem
*
* @see
* screenshot 8
*
* @see
* help output
*/
public class Munch extends DisplayHack {
public long draw_delay;
public int square_count, min_size;
public boolean xor, shift;
public Munch (String [] args) {
super (args, true, true, false, 16, 2000);
draw_delay = option.longg ("draw-delay",
"delay between iterations in millis", 10);
min_size = option.intt ("min-size",
"minimum size of square", 64);
shift = option.booleann ("shift",
"shift factor = munch in random order", true);
square_count = option.intt ("square-count",
"total number of squares", 5);
xor = option.booleann ("xor",
"use xor function to draw", true);
about ("0.1", "munching squares",
"Stephen Tse ",
"http://escher.sourceforge.net/");
if (help_option) return;
// TODO alpha composite (from RENDER/GLX) instead of xor?
if (xor) gc.set_function (gnu.x11.GC.Values.XOR);
}
public void paint () {
int window_size = Math.min (window.width, window.height);
for (int i=0; i