#ifndef SVG_H # define SVG_H // ---------------------------------------------------------------------- // The SVG struct contains the SVG file's width and height as well // as the open FILE pointer but also has a Colors struct 'mColors'. // // This is used as a convenience to specify colors. If we had // an SVG pointer 'svg', we could refer to the color 'red' via: // // svg->mColors.red // // and pass that value to any function requiring a color. // ---------------------------------------------------------------------- typedef struct { const char *none; const char *red; const char *green; const char *blue; const char *black; const char *cyan; const char *magenta; const char *yellow; } Colors; typedef struct { Colors mColors; FILE *mPtr; int mWidth; int mHeight; } SVG; // ---------------------------------------------------------------------- // svgRect - Draw a rectangle at (x, y) with a width of 'width' // and a height of 'height'. // // Can be filled or outlined based upon the values of // 'stroke' and 'fill'. // // Use 'svg->mColors.none' for 'stroke' if you don't // want an edge and for 'fill' if you don't want the // rectangle to be filled. // ---------------------------------------------------------------------- void svgRect( SVG *svg, int x, int y, int width, int height, const char *stroke, const char *fill ); // ---------------------------------------------------------------------- // svgCircle - Draw a circle of radius 'radius' at (x, y). As // with 'svgRect' above, 'stroke' and 'fill' can either // be active or disabled. // ---------------------------------------------------------------------- void svgCircle( SVG *svg, int x, int y, int radius, const char *stroke, const char *fill ); // ---------------------------------------------------------------------- // svgLine - Draw a line from (x1, y1) to (x2, y2) using 'color' // ---------------------------------------------------------------------- void svgLine( SVG *svg, int x1, int y1, int x2, int y2, const char *color ); // ---------------------------------------------------------------------- // svgLineEx - Draw a line from (x1, y1) to (x2, y2) using 'color' // with line width 'strokeWidth' // ---------------------------------------------------------------------- void svgLineEx( SVG *svg, int x1, int y1, int x2, int y2, int strokeWidth, const char *color ); // ---------------------------------------------------------------------- // svgText - Draw the string 'txt' at (x, y) with font size 'size' // ---------------------------------------------------------------------- void svgText(SVG *svg, int x, int y, const char *txt, int size); // ---------------------------------------------------------------------- // svgBorder - Draw a border around the svg picture using color 'stroke' // ---------------------------------------------------------------------- void svgBorder(SVG *svg, const char *stroke); // ---------------------------------------------------------------------- // svgOpen - Open svg file 'fileName', with width 'width' and // height 'height'. The file's title will be 'title' // and this function either returns a pointer to an // SVG object or NULL if the file could not be opened. // ---------------------------------------------------------------------- SVG *svgOpen( const char *fileName, const char *title, int width, int height ); // ---------------------------------------------------------------------- // svgClose - Write the svg footer and close the file. // ---------------------------------------------------------------------- void svgClose(SVG *svg); #endif