import static util.SVGUtil.*;

public class CardGraph {
	private static double startX, startY, width, height;
	private static int cols, rows;

	private static void CardSpec(double sx, double sy, double dx, double dy, int c, int r) {
		startX = sx; startY = sy; width = dx; height = dy;
		cols = c; rows = r;
	}

	private static void f10a4_1() { CardSpec(14, 11, 91, 55, 2, 5); }
	private static void f10a4_2() { CardSpec(18.6, 21.2, 86.4, 50.8, 2, 5); }
	private static void f8a4_5()  { CardSpec(8, 10.5, 97, 69, 2, 4); }

	private static void init() {
	}

	public static void drawFrame() {
		strokeWeight(0.1);
		stroke(bw1(0));
    noFill();
		rect(0, 0, width, height);
	}
	
	private static void drawCard(int n, int i, int j, double ratio) {
    int t;
		drawFrame();  // for debug, comment out

		noStroke();
		for (t = 0; t < 91; t = t + 6) {
      double h = randomInRange(10,59);
      fill(hsb360((t+1)*(i+1)*(j+1)*12,150,300));
      fillOpacity(0.5);
      rect(t+0.5, h, 6, 69-h);
    }
		
	}

	public static void main(String[] args) {
		int i, j, n=0;
		double x;
		a4Portrait();
		start();
		init();
		f8a4_5();
    x = startX;
		for (i=0; i<cols; i++) {
			double y = startY;
			for (j=0; j<rows; j++, n++) {
				pushMatrix();
				translate(x, y);
				drawCard(n, i, j, (double)n/(cols*rows));
				popMatrix();
				y += height;
			}
			x += width;
		}
		finish();
	}
}