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

// program to draw a scarf upon mouse click.

public class Knitting extends WindowController {

    private static final int DIAMETER = 12; // diameter of a stitch

    // spacing between stitches -- will overlap
    private static final int X_DISP = 8;
    private static final int Y_DISP = 8;

    private static final int SCARF_WIDTH = 12; // num stitches per row
    private static final int SCARF_HEIGHT = 40; // num stitches per column

    private static final Color SCARF_COLOR = Color.blue;  // scarf color

    public void begin() {
        new Text("Click to make a scarf", 10, 10, canvas);
    }

    // draws a scarf with upper left at point of click
    public void onMouseClick(Location point) {
        for (int numRows = 0; numRows < SCARF_HEIGHT; numRows++) {
            for (int numCols = 0; numCols < SCARF_WIDTH; numCols++) {
                double x = point.getX() + X_DISP * numCols;
                double y = point.getY() + Y_DISP * numRows;
                FramedOval stitch = new FramedOval(x, y, DIAMETER, DIAMETER, canvas);
                stitch.setColor(SCARF_COLOR);              
            }
        }
    }
}
