1 /* Here is an implementation of these routines for
2 output to Postscript files */
8 #define PTS_PER_INCH 72
11 #define PAGE_WIDTH 8 /* inches */
12 #define PAGE_HEIGHT 8 /* inches */
13 #define P_MAXX ((int)(PAGE_WIDTH*PTS_PER_INCH/P_SCALE_X))
14 #define P_MAXY ((int)(PAGE_HEIGHT*PTS_PER_INCH/P_SCALE_Y))
16 #define P_ORIGIN_Y 100
17 #define P_LINE_WIDTH 1.0
18 #define P_FONT "Courier-Bold"
19 #define P_FONT_SIZE 12
20 #define P_FONT_WIDTH (36.0*P_FONT_SIZE/60)
22 #define P_MAC1 "/x { moveto } def"
23 #define P_MAC2 "/y { lineto } def"
24 #define P_MAC3 "/z { stroke } def"
32 fprintf(outfile,"%c!\ninitgraphics\n",'%');
33 /* Setup scaling etc. */
34 fprintf(outfile,"%-4.2f %-4.2f scale\n",P_SCALE_X,P_SCALE_Y);
35 fprintf(outfile,"%d %d translate\n",P_ORIGIN_X,P_ORIGIN_Y);
36 /* Define some macros */
37 fprintf(outfile,"%s\n%s\n%s\n",P_MAC1,P_MAC2,P_MAC3);
38 /* Default text size etc. */
39 fprintf(outfile,"/%s findfont\n",P_FONT);
40 fprintf(outfile,"%d scalefont\n",(int)(P_FONT_SIZE/P_SCALE_X));
41 fprintf(outfile,"setfont\n");
42 /* Default line width, style etc. */
43 fprintf(outfile,"%-3.1f setlinewidth\n",P_LINE_WIDTH);
44 fprintf(outfile,"%d setlinecap\n",P_LINE_CAP);
45 fprintf(outfile,"[] 0 setdash\n");
51 fprintf(outfile,"showpage\n");
68 /* Flip in Y direction to make origin in bottom left */
73 void draw_line(x1,y1,x2,y2)
76 fprintf(outfile,"%d %d x %d %d y z\n",x1,new_y(y1),x2,new_y(y2));
80 /* Height of descender */
82 return(char_height()/3);
85 void graph_text(x,y,str)
89 fprintf(outfile,"%d %d x (%s) show\n",x,new_y(y)+descender(),str);
92 void choose_line_type(type)
101 case 0 : dashing="[] 0"; width=1.2; break;
102 case 1 : dashing="[6] 0"; width=1.2; break;
103 case 2 : dashing="[4] 1"; width=1.2; break;
104 case 3 : dashing="[] 0"; width=1.8; break;
105 case 4 : dashing="[6] 0"; width=1.8; break;
106 case 5 : dashing="[4] 1"; width=1.8; break;
108 fprintf(outfile,"%-3.1f setlinewidth\n",
110 fprintf(outfile,"%s setdash\n",dashing);
120 return((int)(P_FONT_WIDTH/P_SCALE_X));
125 return((int)(P_FONT_SIZE/P_SCALE_Y));
128 /* End of PostScript specific routines */