#include <math.h>
#include "svg.h"

int nextChar(void) {
    static const int charRange[][2] = {
        { 0x1f425, 0x1f425 },
        { 0x1f427, 0x1f428 },
        { 0x1f42d, 0x1f432 },
        { 0x1f434, 0x1f43c },
    };
    static int current = 0;
    static int nRanges = sizeof(charRange)/(sizeof(int)*2);
    static int c = -1;
    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;
}

int main(void) {
    int i, j;
    double x0 = 20, y0 = 95;

    start();
    rulers();
    textFont("Arial", 8);             /* フォントとサイズ */
    for (i=0; i<6; i++) {
        for (j=0; j<32; j++) {
            double x = j/4.5;   
            double y = (1-i/12.0)*sin(x); 
            fill(hsb1((2*i+j)/32.0, 1, 1));
            text("&#x%x;", x0+x*28, y0-50*y, nextChar());
        }
        x0 += 10; y0 += 5; 
    }
    finish();
    return 0;
}
