inc/psGfx.h

Go to the documentation of this file.
00001 /* PostScript graphics - 
00002  * This provides a bit of a shell around writing graphics to
00003  * a postScript file.  Perhaps the most important thing it
00004  * does is convert 0,0 from being at the bottom left to
00005  * being at the top left. */
00006 
00007 #ifndef PSGFX_H
00008 #define PSGFX_H
00009 
00010 #include "psPoly.h"
00011 
00012 struct psGfx 
00013 /* A postScript output file. */
00014     {
00015     FILE *f;                      /* File to write to. */
00016     double userWidth, userHeight; /* Size of image in virtual pixels. */
00017     double ptWidth, ptHeight;     /* Size of image in points (1/72 of an inch) */
00018     double xScale, yScale;        /* Conversion from pixels to points. */
00019     double xOff, yOff;            /* Offset from pixels to points. */
00020     double fontHeight;            /* Height of current font. */
00021     };
00022 
00023 struct psGfx *psOpen(char *fileName, 
00024         double userWidth, double userHeight, /* Dimension of image in user's units. */
00025         double ptWidth, double ptHeight,     /* Dimension of image in points. */
00026         double ptMargin);                    /* Image margin in points. */
00027 /* Open up a new postscript file.  If ptHeight is 0, it will be
00028  * calculated to keep pixels square. */
00029 
00030 void psClose(struct psGfx **pPs);
00031 /* Close out postScript file. */
00032 
00033 void psTranslate(struct psGfx *ps, double xTrans, double yTrans);
00034 /* add a constant to translate all coordinates */
00035 
00036 void psClipRect(struct psGfx *ps, double x, double y, 
00037         double width, double height);
00038 /* Set clipping rectangle. */
00039 
00040 void psDrawBox(struct psGfx *ps, double x, double y, 
00041         double width, double height);
00042 /* Draw a filled box in current color. */
00043 
00044 void psDrawLine(struct psGfx *ps, double x1, double y1, 
00045         double x2, double y2);
00046 /* Draw a line from x1/y1 to x2/y2 */
00047 
00048 void psFillUnder(struct psGfx *ps, double x1, double y1, 
00049         double x2, double y2, double bottom);
00050 /* Draw a 4 sided filled figure that has line x1/y1 to x2/y2 at
00051  * it's top, a horizontal line at bottom at it's bottom,  and
00052  * vertical lines from the bottom to y1 on the left and bottom to
00053  * y2 on the right. */
00054 
00055 void psXyOut(struct psGfx *ps, double x, double y);
00056 /* Output x,y position transformed into PostScript space. 
00057  * Useful if you're mixing direct PostScript with psGfx
00058  * functions. */
00059 
00060 void psWhOut(struct psGfx *ps, double width, double height);
00061 /* Output width/height transformed into PostScript space. */
00062 
00063 void psMoveTo(struct psGfx *ps, double x, double y);
00064 /* Move PostScript position to given point. */
00065 
00066 void psTextAt(struct psGfx *ps, double x, double y, char *text);
00067 /* Output text in current font at given position. */
00068 
00069 void psTextDown(struct psGfx *ps, double x, double y, char *text);
00070 /* Output text going downwards rather than across at position. */
00071 
00072 void psTextRight(struct psGfx *mg, double x, double y, 
00073         double width, double height, char *text);
00074 /* Draw a line of text right justified in box defined by x/y/width/height */
00075 
00076 void psTextCentered(struct psGfx *mg, double x, double y, 
00077         double width, double height, char *text);
00078 /* Draw a line of text centered in box defined by x/y/width/height */
00079 
00080 void psTimesFont(struct psGfx *ps, double size);
00081 /* Set font to times of a certain size. */
00082 
00083 void psSetColor(struct psGfx *ps, int r, int g, int b);
00084 /* Set current color. r/g/b values are between 0 and 255. */
00085 
00086 void psSetGray(struct psGfx *ps, double grayVal);
00087 /* Set gray value (between 0.0 and 1.0. */
00088 
00089 void psPushG(struct psGfx *ps);
00090 /* Save graphics state on stack. */
00091 
00092 void psPopG(struct psGfx *ps);
00093 /* Pop off saved graphics state. */
00094 
00095 void psDrawPoly(struct psGfx *ps, struct psPoly *poly, boolean filled);
00096 /* Draw a possibly filled polygon */
00097 
00098 void psFillEllipse(struct psGfx *ps, double x, double y, double xrad, double yrad);
00099 
00100 void psDrawEllipse(struct psGfx *ps, double x, double y, double xrad, double yrad,
00101     double startAngle, double endAngle);
00102 
00103 char * convertEpsToPdf(char *epsFile);
00104 /* Convert EPS to PDF and return filename, or NULL if failure. */
00105 
00106 #endif /* PSGFX_H */
00107 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2