#include "figformat.h" /*** NAME figformat PURPOSE NOTES HISTORY mikael - Jan 2, 1995: Created. ***/ #define MAX_BUF 10000 char *fig_box(int left_margin, int top_margin, int width, int height) { char *string, buf[MAX_BUF]; sprintf(buf,"#a box:\n%d %d %d %d %d %d %d %d %5.3lf %d %d %d\n", POLYLINE, /* object-type */ PL_BOX, /* sub-type */ LS_SOLID, /* line-style */ 1, /* pixels */ BLACK, /* colour */ 0, /* depth */ 0, /* pen (not used) */ 0, /* area_fill */ 0.000, /* style-value */ -1, /* radius */ 0, /* a forward arrow ? */ 0); /* a backward arrow ? */ string=(char *)malloc(sizeof(char)*(strlen(buf)+1)); strcpy(string,buf); sprintf(buf,"\t%d %d %d %d %d %d %d %d %d %d 9999 9999\n", left_margin, top_margin, left_margin, top_margin+height, left_margin+width, top_margin+height, left_margin+width, top_margin, left_margin, top_margin); string=(char *)realloc(string,sizeof(char)*(strlen(buf)+strlen(string)+1)); strcat(string,buf); return string; } char *fig_line(int x1, int y1, int x2, int y2, int linestyle) { char *string, buf[MAX_BUF]; sprintf(buf,"#a line:\n%d %d %d %d %d %d %d %d %5.3lf %d %d %d\n", POLYLINE, /* object-type */ PL_POLYLINE, /* sub-type */ linestyle, /* line-style */ 1, /* pixels */ BLACK, /* colour */ 0, /* depth */ 0, /* pen (not used) */ 0, /* area_fill */ 0.000, /* style-value */ -1, /* radius */ 0, /* a forward arrow ? */ 0); /* a backward arrow ? */ string=(char *)malloc(sizeof(char)*(strlen(buf)+1)); strcpy(string,buf); sprintf(buf,"\t%d %d %d %d 9999 9999\n", x1,y1,x2,y2); string=(char *)realloc(string,sizeof(char)*(strlen(buf)+strlen(string)+1)); strcat(string,buf); return string; } char *fig_arrow(int x1, int y1, int x2, int y2, int linestyle) { char *string, buf[MAX_BUF]; sprintf(buf,"#an arrow:\n%d %d %d %d %d %d %d %d %5.3lf %d %d %d\n\t%d %d %d %d %d\n", POLYLINE, /* object-type */ PL_POLYLINE, /* sub-type */ linestyle, /* line-style */ 1, /* pixels */ BLACK, /* colour */ 0, /* depth */ 0, /* pen (not used) */ 0, /* area_fill */ 0.000, /* style-value */ -1, /* radius */ 1, /* a forward arrow ? */ 0, /* a backward arrow ? */ 0, /* arrow type (not used) */ 0, /* arrow style (not used) */ 1, /* arrow thickness */ 5, /* arrow width */ 10); /* arrow height */ string=(char *)malloc(sizeof(char)*(strlen(buf)+1)); strcpy(string,buf); sprintf(buf,"\t%d %d %d %d 9999 9999\n", x1,y1,x2,y2); string=(char *)realloc(string,sizeof(char)*(strlen(buf)+strlen(string)+1)); strcat(string,buf); return string; } char *fig_text(int x1, int y1, int size, char *text) { char *string, buf[MAX_BUF]; sprintf(buf,"#a text-string:\n%d %d %d %d %d %d %d %5.3lf %d %d %d %d %d %s\1\n", TEXT, /* object-type */ 0, /* justification: left */ LS_DEFAULT, /* line-style: font */ size, /* pixels: fontsize */ 0, /* pen: not used */ BLACK, /* color */ 0, /* depth */ 0.000, /* angle */ 4, /* font-flags */ size, /* height */ strlen(text)*(size/2), /* length */ x1, y1, /* coordinate */ text); string=(char *)malloc(sizeof(char)*(strlen(buf)+1)); strcpy(string,buf); return string; }