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

/* program which allows you to draw continuous lines
   on the screen; program chooses a new color
   for the user every time they begin a new scribble */
public class Scribble extends WindowController{

		// first endpoint of next line segment
	private	Location nextLineStarts;
	
		// allows for selection of random r, g, b values
	private RandomIntGenerator colorPicker;
	
		// the current color for drawing
	private Color currentColor;
	
		// create a generator of r, g, b values
	public void begin(){
		colorPicker = new RandomIntGenerator(0, 255);
	}
	
		// save the starting endpoint of the first line
		// and set the current color
	public void onMousePress(Location point){
	
		// select random r, g, b values
		int redness = colorPicker.nextValue();
		int greenness = colorPicker.nextValue();
		int blueness = colorPicker.nextValue();
		
		// create a new color from them
		currentColor = new Color(redness, greenness, blueness);
		
		// save the starting point of the first line to be drawn
		nextLineStarts = point;
		
	}
	
		// draw lines as the user is drags the mouse about
	public void onMouseDrag(Location point){
		new Line(nextLineStarts, point, canvas).setColor(currentColor);
		nextLineStarts = point;
	}
	   
}