45 #define WIDTH_NORMAL 1
48 static char *FillStr =
"<Fill 3>";
49 static char *NoFillStr =
"<Fill 15>";
51 static void mif_ptarray(
GVJ_t * job,
pointf * A,
int n)
55 gvprintf(job,
" <NumPoints %d>\n", n);
56 for (i = 0; i < n; i++)
57 gvprintf(job,
" <Point %.2f %.2f>\n", A[i].x, A[i].y);
66 {
"Black", {0, 0, 0, 100}},
67 {
"White", {0, 0, 0, 0}},
68 {
"Red", {0, 100, 100, 0}},
69 {
"Green", {100, 0, 100, 0}},
70 {
"Blue", {100, 100, 0, 0}},
71 {
"Cyan", {100, 0, 0, 0}},
72 {
"Magenta", {0, 100, 0, 0}},
73 {
"Yellow", {0, 0, 100, 0}},
74 {
"aquamarine", {100, 0, 0, 18}},
75 {
"plum", {0, 100, 0, 33}},
76 {
"peru", {0, 24, 100, 32}},
77 {
"pink", {0, 50, 0, 0}},
78 {
"mediumpurple", {10, 100, 0, 0}},
79 {
"grey", {0, 0, 0, 50}},
80 {
"lightgrey", {0, 0, 0, 25}},
81 {
"lightskyblue", {38, 33, 0, 0}},
82 {
"lightcoral", {0, 50, 60, 0}},
83 {
"yellowgreen", {31, 0, 100, 0}},
86 static void mif_color(
GVJ_t * job,
int i)
88 if (isupper(mif_colors[i].name[0]))
89 gvprintf(job,
"<Separation %d>\n", i);
91 gvprintf(job,
"<ObColor `%s'>\n", mif_colors[i].name);
95 static void mif_style(
GVJ_t * job,
int filled)
99 gvputs(job,
"style=\"fill:");
109 while ((line = *
s++)) {
110 if (
streq(line,
"solid"))
112 else if (
streq(line,
"dashed"))
114 else if (
streq(line,
"dotted"))
116 else if (
streq(line,
"invis"))
118 else if (
streq(line,
"bold"))
120 else if (
streq(line,
"filled"))
122 else if (
streq(line,
"unfilled"))
126 "mif_style: unsupported style %s - ignoring\n",
132 switch (cp->fontopt) {
141 "<Font <FFamily `%s'> <FSize %.1f pt> <FWeight %s> <FAngle %s>>\n",
142 cp->fontfam, job->
scale.
x * cp->fontsz, fw, fa);
144 gvprintf(job,
"<Pen %d> <Fill %d> <PenWidth %d>\n",
145 job->pen, job->fill, job->penwidth);
149 static void mif_comment(
GVJ_t * job,
char *
str)
154 static void mif_color_declaration(
GVJ_t * job,
char *
str,
int CMYK[4])
156 gvputs(job,
" <Color \n");
157 gvprintf(job,
" <ColorTag `%s'>\n", str);
158 gvprintf(job,
" <ColorCyan %d.000000>\n", CMYK[0]);
159 gvprintf(job,
" <ColorMagenta %d.000000>\n", CMYK[1]);
160 gvprintf(job,
" <ColorYellow %d.000000>\n", CMYK[2]);
161 gvprintf(job,
" <ColorBlack %d.000000>\n", CMYK[3]);
162 if (isupper(str[0])) {
163 gvprintf(job,
" <ColorAttribute ColorIs%s>\n", str);
164 gvputs(job,
" <ColorAttribute ColorIsReserved>\n");
166 gvputs(job,
" > # end of Color\n");
170 mif_begin_job(
GVJ_t * job)
173 "<MIFFile 3.00> # Generated by %s version %s (%s)\n",
177 static void mif_end_job(
GVJ_t * job)
179 gvputs(job,
"# end of MIFFile\n");
182 static void mif_begin_graph(
GVJ_t * job)
189 gvputs(job,
"<Units Upt>\n");
190 gvputs(job,
"<ColorCatalog \n");
191 for (i = 0; i < (
sizeof(mif_colors) /
sizeof(
mif_color_t)); i++)
192 mif_color_declaration(job, mif_colors[i].name, mif_colors[i].CMYK);
193 gvputs(job,
"> # end of ColorCatalog\n");
194 gvprintf(job,
"<BRect %g %g %g %g>\n",
202 mif_begin_page(
GVJ_t *job)
205 " <ArrowStyle <TipAngle 15> <BaseAngle 90> <Length %.1f> <HeadType Filled>>\n",
209 static void mif_set_color(
GVJ_t * job,
char *name)
213 for (i = 0; i < (
sizeof(mif_colors)/
sizeof(
mif_color_t)); i++) {
214 if (
strcasecmp(mif_colors[i].name, name) == 0)
217 agerr(
AGERR,
"color %s not supported in MIF\n", name);
220 static char *mif_string(
GVJ_t * job,
char *
s)
222 static char *buf =
NULL;
223 static int bufsize = 0;
229 buf = malloc(bufsize);
234 if (pos > (bufsize - 8)) {
236 buf = realloc(buf, bufsize);
265 static void mif_textpara(
GVJ_t * job,
pointf p, textpara_t * para)
270 switch (para->just) {
283 "<TextLine <Angle %d> <TLOrigin %.2f %.2f> <TLAlignment %s>",
285 gvprintf(job,
" <String `%s'>>\n", mif_string(job, para->str));
288 static void mif_bezier(
GVJ_t * job,
pointf * A,
int n,
int arrow_at_start,
289 int arrow_at_end,
int filled)
292 "<PolyLine <Fill 15> <Smoothed Yes> <HeadCap Square>\n");
293 mif_ptarray(job, A, n);
297 static void mif_polygon(
GVJ_t * job,
pointf * A,
int n,
int filled)
299 gvprintf(job,
"<Polygon %s\n", (filled ? FillStr : NoFillStr));
300 mif_ptarray(job, A, n);
304 static void mif_ellipse(
GVJ_t * job,
pointf * A,
int filled)
308 dia.
x = (A[1].
x - A[0].
x) * 2;
309 dia.
y = (A[1].
y - A[0].
y) * 2;
311 gvprintf(job,
"<Ellipse %s <BRect %.2f %.2f %.1f %.1f>>\n",
312 filled ? FillStr : NoFillStr,
313 A[1].x - dia.
x, A[1].
y, dia.
x, -dia.
y);
316 static void mif_polyline(
GVJ_t * job,
pointf * A,
int n)
318 gvputs(job,
"<PolyLine <HeadCap Square>\n");
319 mif_ptarray(job, A, n);
int agerr(agerrlevel_t level, const char *fmt,...)
gvplugin_installed_t gvdevice_mif_types[]
#define GVRENDER_Y_GOES_DOWN
int gvputs(GVJ_t *job, const char *s)
gvrender_engine_t mif_engine
gvplugin_installed_t gvrender_mif_types[]
int strcasecmp(const char *s1, const char *s2)
gvrender_features_t mif_features
void gvprintf(GVJ_t *job, const char *format,...)