static void rtbox(double r,double theta,double wtheta,const char *label) { coord v[4]; double htheta,hr; htheta=wtheta/2; hr=r*htheta; v[0]=rt(r-hr,theta-htheta); v[1]=rt(r+hr,theta-htheta); v[2]=rt(r+hr,theta+htheta); v[3]=rt(r-hr,theta+htheta); startgroup(); printf("<path "LT" d=\"M%f %f L%f %f L%f %f L%f %f Z\"/>\n", XY(v[0]),XY(v[1]),XY(v[2]),XY(v[3])); crosshair(rt(r,theta),5); text_cen(rt(r+0.8*hr,theta),theta,24,label); endgroup(); }
int main(void) { const double scale=100; double inner=2.80,outer=3.40; double lp=29.53; /* lunar period for earthly observer */ int i; start(8.5,11,scale); text_cen(xy(0,scale*(-1-outer)),0,36,"Lunar Calendar Template"); /* boudaries */ circle(xy(0,0),scale*3.75); circle(xy(0,0),scale*2.25); //circle(xy(0,0),scale*inner); //circle(xy(0,0),scale*outer); crosshair(xy(0,0),0.1*scale); startgroup(); for(i=0;i<31;i++) { char date[6]; double r; #if SPIRAL r=(inner + (outer-inner)*i/lp); #endif #if TWOLAYER r=((i<29)?inner:outer); #endif sprintf(date,"%d",1+i); rtbox(r*scale,2*pi*i/lp,2*pi/lp,date); } endgroup(); end(); return 0; }
inline void MacroAssembler::endgroup_if_needed(bool needed) { if (needed) { endgroup(); } }
static void crosshair(coord o,double r) { startgroup(); circle(o,r); cross(o,r*2); endgroup(); }