import static util.Common.PI;
import static util.SVGUtil.*;

public class CharRainbow {
    private final static String str[] = {  // ★　絵文字などの指定
        "&#9829;", 
        "香",
        "&#9830;", 
        "川", 
        "&#9824;", 
        "大", 
        "&#9827;",
        "学", 
        "&#9833;",
        "創",
        "&#9834;",
        "造",
        "&#9835;",
        "工", 
        "&#9836;",
        "学", 
        "&#9837;",
        "部",
        "&#9838;",

    };
    private static final int numStr = str.length;
    private static int k = 0;

    private static String nextStr() {
        String ret = str[k++];
        if (k >= numStr) {
            k = 0;
        }
        return ret;
    }

    private static final double hues[] = { 0, 0.111, 0.222, 0.333, 0.5, 0.666, 0.777 };  /* 色相　これくらいが自然？ */
    private static final double maxR = 80, minR = 50;  /* 外側の虹、内側の虹の半径 */
    private static final int space = 6;                /* 文字の間隔の目安 */
    private static final int num = hues.length;        /* 虹の色数 */

    public static void main(String[] args) {
        int i, j;

        double fontSize = 5;    /* フォントサイズ */

        start();
        rulers();
        textFont("Segoe UI Symbol", fontSize);
        translate(centerX() - 40, centerY() * 1.6);
        for (i = 0; i < num; i++) {
            double r, len;
            int n; 
            r = maxR + (minR - maxR) / (num - 1) * i;
            len = PI * r;
            n = (int) (len / space); 
            fill(hsb1(hues[i], 1, 1));
            for (j = 0; j <= n; j++) {
                double angle = - PI +  PI * j / n;
                double x = Math.cos(angle), y = Math.sin(angle);
                pushMatrix();
                translate(r*x, r*y);
                rotate(angle + PI / 2);                  // ★　文字を常にまっすぐ立てるときはコメントアウト 
                translate(-fontSize / 2, fontSize / 2);
                text(nextStr(), 0, 0);
                popMatrix();
            } 
        }
        finish();
    }
}
