Rev 8076 | Rev 8134 | Go to most recent revision | 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 | |||
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 | |||
22 | #include "flydraw.h" |
||
23 | |||
24 | char imagefilename[1024]; |
||
1024 | bpr | 25 | char vimgfilename[1024]; |
10 | reyssat | 26 | int sizex, sizey, saved; |
27 | gdImagePtr image=NULL, brushimg=NULL, tileimg=NULL, wimg=NULL; |
||
28 | int brushed=0,tiled=0,styled=0,width=1, savew=1, wcolor=-1; |
||
29 | int color_white,color_black,color_bounder; |
||
30 | int linecnt=-100000; |
||
31 | int tranged=0; |
||
32 | double xscale=1,yscale=1,xstart=0,ystart=0; |
||
33 | double tstart=0,tend=1,tstep=100,plotjump=200; |
||
34 | double animstep=0; |
||
7675 | bpr | 35 | int transform=0; /* transformation indicator */ |
36 | double transx=0,transy=0; /* translation vector */ |
||
10 | reyssat | 37 | int lstep=4; |
38 | ev_variable vartab[MAX_VARS]; |
||
39 | char varnamebuf[MAX_VARNAMEBUF], *varnameptr=varnamebuf; |
||
40 | int varcnt; |
||
7675 | bpr | 41 | int vimg=0; /* 0: no vector image output. |
42 | * 1: DXF vector output. */ |
||
43 | int vimg_enable=0; /* 0: disable. 1: enable. */ |
||
1024 | bpr | 44 | int vimg_ready=0; |
45 | FILE *vimgf=NULL; |
||
46 | double scale_buf[MAX_PARMS]; |
||
10 | reyssat | 47 | /***** Les modifs a JC Fev 06 *****/ |
48 | /** les matrices suivantes sont initialisees par la commande setmatrix nummatrix,a11,a12,a21,a22 */ |
||
49 | /** elles sont remises a l'unite par resetmatrix nummatrix */ |
||
8102 | bpr | 50 | |
10 | reyssat | 51 | /* la matrice fixant le systeme de coordonnees "mathematiques" dans l'image */ |
8076 | bpr | 52 | matrice matrices_pavage[JC_NB_MATRICES+1]; |
53 | vecteur vecteurs_pavage[JC_NB_MATRICES+1]; |
||
10 | reyssat | 54 | |
55 | /** les coordonnees du parallelograme de pavage = coordonnees "mathematiques" du parallelogramme contenant l'image a recopier **/ |
||
56 | /** on place ces coorodonnes avec setparallelogram xs,ys,xu,yu,xv,yu **/ |
||
7675 | bpr | 57 | /* xs,ys=coordonnees math du point 0,0, |
10 | reyssat | 58 | * xu,yu coordonnees math de l'horizontale |
59 | * xv,yv coordonnees math de la verticale |
||
60 | * ces coordonnees sont remises a leur valeur par defaut par resetparallelogram |
||
61 | */ |
||
62 | /** TODO serait-ce un moyen de definir la brush ?? **/ |
||
63 | double parallogram_fonda[]={0,0,100,0,0,100}; |
||
64 | |||
65 | /**** Fin modifs JC Fev 06 ******/ |
||
66 | |||
7675 | bpr | 67 | /* Write the image */ |
10 | reyssat | 68 | void output(void) |
69 | { |
||
70 | FILE *out; |
||
71 | |||
72 | if(!image) return; |
||
73 | if(imagefilename[0]) { |
||
7675 | bpr | 74 | out=fopen(imagefilename,"wb"); |
75 | if(out!=NULL) {gdImageGif(image,out); fclose(out); } |
||
10 | reyssat | 76 | } |
77 | else gdImageGif(image,stdout); |
||
78 | saved=1; |
||
79 | } |
||
80 | |||
8102 | bpr | 81 | /*#include "flylines.c"*/ |
82 | /*#include "nametab.c"*/ |
||
8076 | bpr | 83 | |
84 | /* substitute variable names by their environment strings |
||
85 | * The buffer pointed to by p must have enough space |
||
8102 | bpr | 86 | * (defined by MAX_LINELEN). |
87 | */ |
||
8076 | bpr | 88 | char *substit(char *p) |
89 | { |
||
90 | char *pp, *pe; |
||
91 | char namebuf[MAX_NAMELEN+1]; |
||
92 | int i, l; |
||
93 | |||
94 | pe=strchr(p,'"'); if(pe!=NULL) l=pe-p; else l=MAX_LINELEN; |
||
95 | for(pp=find_name_start(p); *pp!=0 && pp-p<l; |
||
96 | pp=find_name_start(pe)) { |
||
97 | pe=find_name_end(pp); |
||
98 | if((pp>p && !isspace(*(pp-1)) && *(pp-1)!=',') || |
||
99 | (*pe!=0 && !isspace(*pe) && *pe!=',')) continue; |
||
100 | memmove(namebuf,pp,pe-pp); namebuf[pe-pp]=0; |
||
101 | i=search_list(nametab,nametab_no,sizeof(nametab[0]),namebuf); |
||
102 | if(i<0) continue; |
||
103 | if(nametab[i].type==t_prep && preptab[nametab[i].serial].typ==p_font) |
||
104 | break; |
||
105 | if(nametab[i].type==t_color) |
||
106 | string_modify(p,pp,pe,colortab[nametab[i].serial].def); |
||
107 | } |
||
108 | return p; |
||
109 | } |
||
110 | |||
8102 | bpr | 111 | /*#include "vimg.c"*/ |
112 | /*#include "objects.c"*/ |
||
10 | reyssat | 113 | |
114 | void process(void) |
||
115 | { |
||
116 | char buf[MAX_LINELEN+1]; |
||
117 | int c; |
||
118 | do { |
||
7675 | bpr | 119 | c=ggetline(buf); obj_main(buf); |
10 | reyssat | 120 | } |
121 | while(c!=EOF); |
||
122 | } |
||
123 | |||
124 | int verify_tables(void) { |
||
125 | return evaltab_verify(); |
||
126 | } |
||
127 | |||
128 | int main(int argc, char *argv[]) |
||
129 | { |
||
8076 | bpr | 130 | int i; for (i = 0; i <= JC_NB_MATRICES; i++) |
131 | matrices_pavage [i][0] = matrices_pavage[i][3] = 1; |
||
10 | reyssat | 132 | error1=error; error2=error; error3=error; |
133 | substitute=substit; |
||
134 | ev_varcnt=&varcnt; ev_var=vartab; |
||
135 | if(argc==2 && strcasecmp(argv[1],"table")==0) { |
||
7675 | bpr | 136 | if(verify_tables()) { |
137 | printf("Table disorder.\n"); return 1; |
||
138 | } |
||
139 | printf("Table orders OK.\n"); return 0; |
||
10 | reyssat | 140 | } |
141 | vartab[0].name="animstep"; vartab[0].value=0; |
||
142 | varcnt=1; |
||
143 | if(argc>1) snprintf(imagefilename,sizeof(imagefilename),"%s",argv[1]); |
||
144 | else imagefilename[0]=0; |
||
145 | process(); |
||
146 | if(!saved || imagefilename[0]!=0) output(); |
||
147 | if(image) gdImageDestroy(image); |
||
1024 | bpr | 148 | if(vimg_ready) vimg_close(); |
10 | reyssat | 149 | return 0; |
150 | } |
||
151 |