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

/*
 * Example VanishingScribble: draw using lines that either fall off the canvas
 * or fade away.
 *
 * Jim Teresco, Siena College, CSIS 120, Fall 2011
 *
 * $Id: VanishingScribble.java 1553 2011-02-28 02:11:43Z terescoj $
 */

public class VanishingScribble extends WindowController {

    // random generator to pick line types
    private RandomIntGenerator whichType = new RandomIntGenerator(0,2);
    // the current line type: 0=fading, 1=falling, 2=rising
    private int lineType;

    // location of last mouse position to draw scribble components
    private Location lastMouse;

    // pick a type of line (fading or falling) for this scribble
    // and remember starting point
    public void onMousePress(Location point) {

        lineType = whichType.nextValue();
        lastMouse = point;
    }

    // draw a segment of the appropriate type of line then update lastMouse
    public void onMouseDrag(Location point) {

        if (lineType == 0) {
            new FadingLine(lastMouse, point, canvas);
        }
        else if (lineType == 1) {
            new FallingLine(lastMouse, point, canvas);
        }
        else {
            new RisingLine(lastMouse, point, canvas);
        }
        lastMouse = point;
    }
}
