/***************************/ /* Encapsulated Postscript */ /* Output version 1.0 */ /* */ /* Ju Li Jan. 9 1998 MIT */ /***************************/ #include "P.h" /* the only bootstrapping bit */ static int P_in_use = 0; /* needed to be preset */ static char filename[P_MAX_STRLEN+1]; static FILE *P; static double H[2][2], O[2], M[2], C[2]; /* the following has to be initialized by P */ static double lred, lgreen, lblue; #define default(b,A,C,d) (((b)==(A)(C))?(d):(b)) #define normal(a) (((a)>=-P_TINY)&&((a)<=1+P_TINY)) #define same(a,b) (((a)>(b)-P_TINY)&&((a)<(b)+P_TINY)) #define norm(x,y) (sqrt((x)*(x)+(y)*(y))) #define max(x,y) ((x)>(y)?(x):(y)) /* Transform a point on rectangular domain (0,M[0]) * (0,M[1]) */ /* to Postscript coordinates on paper according to H[][] and O[] */ void PTran (int n, double *in, double *out) { int i; double inr[2]; for (i=0; i.\n", P_VERSION ); PSetRGBColor(0,0,0); /* physically draw out and clip the H[2][] domain */ PDrawRectangle (0, 0, M[0], M[1], P_CLIP); return (P); } /* end PInit() */ char *PClose () { fprintf(P, "showpage\n"); fclose(P); P_in_use = 0; return (filename); } /* end PClose() */ #ifdef P_TEST int main (int argc, char *argv[]) { PInit( (argc>1)?argv[1]:"P_DEFAULT", P_DEFAULT, 0.5, /* H[0][] in inches */ 0.5, P_DEFAULT, /* H[1][] in inches */ P_DEFAULT, P_DEFAULT, /* Origin in inches */ P_DEFAULT, P_DEFAULT /* Unit in inches */ ); /* PDrawDashRectangle (0, 0, 1, 1); */ PSetRGBColor (1,0,0); PDrawDashLine (0., 0., 2., 2.); PSetRGBColor (0,0,1); PDrawDashCircle (0.5, 0.5, 0.6); PDrawDashCircle (0.5, 0.5, 0.3); PDrawDashCircle (0.5, 0.5, 0.1); PSetRGBColor (0,1,0); PDrawCircle (0.5, 0.5, 0.05, P_FILL); PSetRGBColor (0,0,0); PDrawLine (0, 1, 1, 0); PClose (); return(1); } #endif