//
// Buren - applet that draws modern art
//
//  Written by: Mathias Fuchs   5/16/1997
//  	Mathias.Fuchs@siba.fi
//
//  -- Applet inspired by Richie Bielak's Mondrian Applet --
//  -- Just please keep my name in.     --
//

import java.applet.*;
import java.awt.*;


public class Buren extends Applet {

// Width of picture
private int pic_width;

// Height of picture
private int pic_height;

private Color farbe;

// init applet
public void init() {
	// Get parameters that describe the size of our window
	String pvalue;

	pvalue = getParameter ("width");
	pic_width = Integer.parseInt (pvalue, 10);
	pvalue = getParameter ("height");
	pic_height = Integer.parseInt (pvalue, 10);
	//
} // init


public void paint (Graphics g) {

	g.setColor (Color.white);
	g.fillRect (1, 1, pic_width, pic_height);
	buren (g, 1, 1, pic_width, pic_height, 4);


} // paint


public void buren (Graphics g, 
				int x, 
				int y, 
				int width,	
				int height,
				int depth) {

	int middle, index;

		middle = (int)(Math.random() * width);
		// Draw lines
		setRandomColor (g);
		for (index=0;index<pic_width/30; index++)
		{
		g.fillRect (x + 30*index, y, x + 30*index + 15, y+pic_height);
		g.setColor (Color.white);
		g.fillRect (x + 30*index+15, y, x + 30*index + 30, y+pic_height);
		setRandomColor (g);
		}
	
} 

public void setRandomColor (Graphics g) {
	double x;
	int xi;

	x = 255.0 * Math.random ();
	xi= (int) x;
	farbe = new Color(xi,xi,0);
	g.setColor (farbe);
}


public boolean mouseDown (Event e, int x, int y) {
	Graphics g = getGraphics ();
	paint (g);
	return true;
}


}