
import objectdraw.*;
import java.awt.*;

/**
 * See <http://www.jacksonpollock.org/>
 */
public class PaintLikeJacksonPollock extends WindowController {

  private static final int INITIAL_SIZE = 20;
  private static final int MIN_SIZE = 2;
  private static final int MAX_SIZE = 10;

  private RandomIntGenerator randomColor = new RandomIntGenerator(0, 255);
  private RandomIntGenerator randomSize = new RandomIntGenerator(MIN_SIZE, MAX_SIZE);

  private Color currentColor;
  private int spotSize;

  public void begin() {
    currentColor = Color.white;
  }

  public void onMousePress(Location point) {
    currentColor = new Color(randomColor.nextValue(), 
                             randomColor.nextValue(), 
                             randomColor.nextValue());
    new FilledOval(point, INITIAL_SIZE, INITIAL_SIZE, canvas).setColor(currentColor);
  }

  public void onMouseMove(Location point) {
    spotSize = randomSize.nextValue();
    new FilledOval(point, spotSize, spotSize, canvas).setColor(currentColor);
  }

}
