import static util.SVGUtil.*;

public class Reflect {
    private 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;
    }

    public static void main(String[] args) {
        double x = centerX(), y = centerY();

        double fontSize = 6;                                     /* フォントサイズ */
        double dx = PHI * fontSize * 1.5, dy = fontSize * 1.5;   /* 初速度の x成分, y成分 */
        double lB = 20, rB = pageWidth() - 20, uB = 40, dB = pageHeight() - 40;       /* 壁の座標 */
        double angle = Math.atan2(dy, dx);
        int num = 200;                                           /* 描く文字の総数 */
        int i;

        start();
        rulers();
        fillOpacity(0.7);

        textFont("Segoe UI Symbol", fontSize);             
        for (i = 0; i < num; i++) {
            fill(hsb1(i / 24.0 * PHI, 1, 1));
            pushMatrix();
            translate(x, y);
            rotate(angle);
            translate(-fontSize / 2, fontSize / 2);
            text(nextStr(), 0, 0);
            popMatrix(); 
            x += dx; y += dy;
            if (x < lB) {
                x = 2 * lB - x;
                dx *= -1;
                angle = Math.atan2(dy, dx);
            } else if (x > rB) {
                x = 2 * rB - x;
                dx *= -1;
                angle = Math.atan2(dy, dx);
            }

            if (y < uB) {
                y = 2 * uB - y;
                dy *= -1;
                angle = Math.atan2(dy, dx);
            } else if (y>dB) {
                y = 2 * dB - y;
                dy *= -1;
                angle = Math.atan2(dy, dx);
            }
        }
        finish();
    }
}
