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) {
                double x = point.getX();
                double y = point.getY(); // x and y positions of the next "stitch"

                int numRows = 0;
                int numCols = 0;

                while (numRows < SCARF_HEIGHT) {

                    numCols = 0;
                        x = point.getX();
                        while (numCols < SCARF_WIDTH) {
                                FramedOval stitch = new FramedOval(x, y, DIAMETER, DIAMETER, canvas);
                                stitch.setColor(SCARF_COLOR);
                                x = x + X_DISP;
                                numCols++;
                        }
                        
                        y = y + Y_DISP;
                        numRows++;
                }
        }
}
