Rev 18133 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
8134 | bpr | 18 | /* This file is a temporary patch to tex eps files with extra borders. |
19 | * It cuts the borders in the resulting gif file, so that the font |
||
20 | * fits tightly in the cadre. libgd is required. |
||
21 | */ |
||
10 | reyssat | 22 | |
23 | #include "flydraw.h" |
||
24 | |||
17574 | bpr | 25 | FILE *tikz_file; |
26 | |||
10 | reyssat | 27 | char imagefilename[1024]; |
1024 | bpr | 28 | char vimgfilename[1024]; |
17574 | bpr | 29 | char tikzfilename[1024]; |
10 | reyssat | 30 | int sizex, sizey, saved; |
31 | gdImagePtr image=NULL, brushimg=NULL, tileimg=NULL, wimg=NULL; |
||
8414 | bpr | 32 | int brushed=0, tiled=0, styled=0, width=1, savew=1, wcolor=-1, width2=4; |
18159 | bpr | 33 | int dashed,filled,noreset; |
8158 | bpr | 34 | int color_white, color_black, color_bounder, color_frame; |
10 | reyssat | 35 | int linecnt=-100000; |
36 | int tranged=0; |
||
8158 | bpr | 37 | double xscale=1, yscale=1, xstart=0, ystart=0; |
38 | double tstart=0, tend=1, tstep=100, plotjump=200; |
||
10 | reyssat | 39 | double animstep=0; |
7675 | bpr | 40 | int transform=0; /* transformation indicator */ |
8158 | bpr | 41 | double transx=0, transy=0; /* translation vector */ |
10 | reyssat | 42 | int lstep=4; |
43 | ev_variable vartab[MAX_VARS]; |
||
44 | char varnamebuf[MAX_VARNAMEBUF], *varnameptr=varnamebuf; |
||
45 | int varcnt; |
||
7675 | bpr | 46 | int vimg=0; /* 0: no vector image output. |
47 | * 1: DXF vector output. */ |
||
48 | int vimg_enable=0; /* 0: disable. 1: enable. */ |
||
1024 | bpr | 49 | int vimg_ready=0; |
50 | FILE *vimgf=NULL; |
||
51 | double scale_buf[MAX_PARMS]; |
||
8134 | bpr | 52 | /* les matrices suivantes sont initialisees par la commande setmatrix nummatrix,a11,a12,a21,a22 |
53 | * elles sont remises a l'unite par resetmatrix nummatrix |
||
54 | * la matrice fixant le systeme de coordonnees "mathematiques" dans l'image |
||
55 | */ |
||
8076 | bpr | 56 | matrice matrices_pavage[JC_NB_MATRICES+1]; |
57 | vecteur vecteurs_pavage[JC_NB_MATRICES+1]; |
||
10 | reyssat | 58 | |
8134 | bpr | 59 | /* les coordonnees du parallelograme de pavage = coordonnees "mathematiques" |
17633 | bpr | 60 | * du parallelogramme contenant l'image a recopier on place ces coordonnees |
8134 | bpr | 61 | * avec setparallelogram xs,ys,xu,yu,xv,yu |
62 | * xs,ys=coordonnees math du point 0,0, |
||
10 | reyssat | 63 | * xu,yu coordonnees math de l'horizontale |
64 | * xv,yv coordonnees math de la verticale |
||
65 | * ces coordonnees sont remises a leur valeur par defaut par resetparallelogram |
||
66 | */ |
||
67 | double parallogram_fonda[]={0,0,100,0,0,100}; |
||
68 | |||
7675 | bpr | 69 | /* Write the image */ |
10 | reyssat | 70 | void output(void) |
71 | { |
||
12473 | bpr | 72 | FILE *out; |
10 | reyssat | 73 | |
12473 | bpr | 74 | if(!image) return; |
75 | if(imagefilename[0]) { |
||
76 | out=fopen(imagefilename,"wb"); |
||
77 | if(out!=NULL) {gdImageGif(image, out); fclose(out); } |
||
78 | } |
||
79 | else gdImageGif(image, stdout); |
||
80 | saved=1; |
||
10 | reyssat | 81 | } |
82 | |||
8076 | bpr | 83 | /* substitute variable names by their environment strings |
84 | * The buffer pointed to by p must have enough space |
||
8102 | bpr | 85 | * (defined by MAX_LINELEN). |
86 | */ |
||
8076 | bpr | 87 | char *substit(char *p) |
88 | { |
||
12473 | bpr | 89 | char *pp, *pe; |
90 | char namebuf[MAX_NAMELEN+1]; |
||
91 | int i, l; |
||
8076 | bpr | 92 | |
12473 | bpr | 93 | pe=strchr(p,'"'); if(pe!=NULL) l=pe-p; else l=MAX_LINELEN; |
94 | for(pp=find_name_start(p); *pp!=0 && pp-p<l; |
||
95 | pp=find_name_start(pe)) { |
||
96 | pe=find_name_end(pp); |
||
97 | if((pp>p && !isspace(*(pp-1)) && *(pp-1)!=',') || |
||
98 | (*pe!=0 && !isspace(*pe) && *pe!=',')) continue; |
||
99 | memmove(namebuf,pp,pe-pp); namebuf[pe-pp]=0; |
||
100 | i=search_list(nametab,nametab_no,sizeof(nametab[0]),namebuf); |
||
101 | if(i<0) continue; |
||
102 | if(nametab[i].type==t_prep && preptab[nametab[i].serial].typ==p_font) |
||
103 | break; |
||
104 | if(nametab[i].type==t_color) |
||
105 | string_modify(p,pp,pe,colortab[nametab[i].serial].def); |
||
106 | } |
||
107 | return p; |
||
8076 | bpr | 108 | } |
109 | |||
8878 | bpr | 110 | void fly_process(void) |
10 | reyssat | 111 | { |
12473 | bpr | 112 | char buf[MAX_LINELEN+1]; |
113 | int c; |
||
114 | do { |
||
115 | c=ggetline(buf); obj_main(buf); |
||
116 | } |
||
117 | while(c!=EOF); |
||
10 | reyssat | 118 | } |
119 | |||
120 | int verify_tables(void) { |
||
12473 | bpr | 121 | return evaltab_verify(); |
10 | reyssat | 122 | } |
123 | |||
124 | int main(int argc, char *argv[]) |
||
125 | { |
||
8076 | bpr | 126 | int i; for (i = 0; i <= JC_NB_MATRICES; i++) |
12473 | bpr | 127 | matrices_pavage [i][0] = matrices_pavage[i][3] = 1; |
128 | substitute=substit; |
||
129 | ev_varcnt=&varcnt; ev_var=vartab; |
||
130 | if(argc==2 && strcasecmp(argv[1],"table")==0) { |
||
131 | if(verify_tables()) { |
||
132 | printf("Table disorder.\n"); return 1; |
||
10 | reyssat | 133 | } |
12473 | bpr | 134 | printf("Table orders OK.\n"); return 0; |
135 | } |
||
136 | vartab[0].name="animstep"; vartab[0].value=0; |
||
137 | varcnt=1; |
||
138 | if(argc>1) snprintf(imagefilename,sizeof(imagefilename),"%s",argv[1]); |
||
139 | else imagefilename[0]=0; |
||
140 | fly_process(); |
||
17574 | bpr | 141 | if(tikz_file){ |
17755 | bpr | 142 | fprintf(tikz_file,"\\end{tikzpicture}\n"); |
17574 | bpr | 143 | fclose(tikz_file); |
144 | } |
||
17916 | bpr | 145 | else |
146 | if(!saved || imagefilename[0]!=0) output(); |
||
12473 | bpr | 147 | if(image) gdImageDestroy(image); |
148 | if(vimg_ready) vimg_close(); |
||
149 | return 0; |
||
10 | reyssat | 150 | } |