import static util.SVGUtil.*;

public class Parametric {
	private static final int charRange[][] = {
		{ 0x1f425, 0x1f43c },
		{ 0x1f380, 0x1f393 }
	};
	
	private static int current = 0;
	private static final int nRanges = charRange.length;
	private static int c = -1;

	private static int nextChar() {
		int nextC;
		if (c==-1) {
			c = charRange[current][0];
		}       
		nextC = c++;
		if (c > charRange[current][1]) {
			current++;
			if (current >= nRanges) {
				current = 0;
			}    
			c = charRange[current][0];
		}   

		return nextC;
	}

	private final static int M = 6;

	private static double fx(double t) {  /* -1 〜 1 の範囲 */
		return t*Math.cos(M*2*PI*t);
	}

	private static double fy(double t) {  /* -1 〜 1 の範囲 */
		return t*Math.sin(M*2*PI*t);
	}

//	private static double dx(double t) {  /* fx の微分 */
//		return -M*2*PI*t*Math.sin(M*2*PI*t)+Math.cos(M*2*PI*t);
//	}
//
//	private static double dy(double t) {  /* fy の微分 */
//		return M*2*PI*t*Math.cos(M*2*PI*t)+Math.sin(M*2*PI*t);
//	}

	public static void main(String[] args) {
		int i;
		int num = 128;   /* 文字数の目安 */

		double fontSize = 6; /* フォントサイズ */

		start();
		rulers();
		textFont("Segoe UI Symbol", fontSize);
		pushMatrix();
		translate(centerX()-50, centerY());
		for (i=32; i<num; i++) {   /* 少し中心から離れたところから始める */
			double x = fx(i/(num-1.0));   
			double y = fy(i/(num-1.0)); 
			fill(hsb1(i/16.0, 1, 1));
			text("&#x%x;", x*55, 60*y+fontSize/2, nextChar());  
		}
		popMatrix();
		
		fontSize = 4;
		textFont("Segoe UI Symbol", fontSize); 	
		pushMatrix();

		popMatrix();
		translate(centerX()+55, centerY()+15);
		for (i=32; i<num; i++) {   /* 少し中心から離れたところから始める */
			double x = -fx(i/(num-1.0));   
			double y = fy(i/(num-1.0)); 
			fill(hsb1(i/16.0, 1, 1));
			text("&#x%x;", x*35, 40*y+fontSize/2, nextChar());  
		}	
		finish();
	}
}
