import static util.SVGUtil.*;

public class CardTori {
	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 double rx=97/2, ry=58, w=85, h=85;
  private static int[] color={0xff0000, 0xffa500, 0xffff00, 0x008000, 
                     0x00ffff, 0x0000ff, 0x800080, 0xff0000, 
                     0xffa500, 0xffff00};

	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() {
	}

	private static void drawFrame() {
		strokeWeight(0.1);
		stroke(bw1(0));
    noFill();
		rect(0, 0, width, height);
	}

	private static void drawRainbow(int l, double rw, double rh) {
		int k;
		drawFrame();  // for debug, comment out

    for (k=0; k<l; k++) {
      stroke(color[k]);
      strokeWeight(5);
      noFill();
      arc(rx, ry, rw, rh, PI, 2*PI);
      rw-=10;rh-=10;
    }
	}

	public static void main(String[] args) {
		int i, j, n=0, l=1;
		double x;

		a4Portrait();
		start();
		init();
		f8a4_5();

    x = startX;
		for (i=0; i<cols; i++) {
			double y = startY;
			for (j=0; j<rows; j++) {
				pushMatrix();
				translate(x, y);
				drawRainbow(l++, w, h);
				popMatrix();
				y += height;
			}
			x += width;
		}
		finish();
	}
}
