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

/*
 * Another spirograph program.  This time it creates lines of
 * any randomly chosen color.
 */
public class VeryColorfulSpirograph extends WindowController {

    // first coordinate of a line segment
    private Location start;

    // color of next spriograph
    private Color currentColor;

    // generator for random color values
    private RandomIntGenerator randomIntensity = new RandomIntGenerator(0, 255);

    /*
     * Save the first coordinate of the line, and pick
     * a new color at random.
     */
    public void onMousePress(Location point) {
  
        start = point;

        // Create a new random color, with values from
        // 0..255 for the Red, Green, and Blue parts
        currentColor = new Color(randomIntensity.nextValue(), 
                                 randomIntensity.nextValue(),
                                 randomIntensity.nextValue());

    }

    public void onMouseDrag(Location point) {
        new Line(start, point, canvas).setColor(currentColor);
    }


    public void onMouseEnter(Location pt) {
        canvas.clear();
    }

}
