Subversion Repositories wimsdev

Rev

Rev 1024 | Go to most recent revision | Details | 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
#include "../Lib/libwims.h"
24
 
25
char imagefilename[1024];
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;
35
double matrix[]={1,0,0,1};      /* transformation matrix */
36
int transform=0;                /* transformation indicator */
37
double transx=0,transy=0;       /* translation vector */
38
int lstep=4;
39
ev_variable vartab[MAX_VARS];
40
char varnamebuf[MAX_VARNAMEBUF], *varnameptr=varnamebuf;
41
int varcnt;
42
/***** Les modifs a JC Fev 06 *****/
43
/** les matrices suivantes sont initialisees par la commande setmatrix nummatrix,a11,a12,a21,a22 */
44
/** elles sont remises a l'unite par resetmatrix nummatrix */
45
double matrix01[] = {1,0,0,1};
46
double matrix02[] = {1,0,0,1};
47
double matrix03[] = {1,0,0,1};
48
double matrix04[] = {1,0,0,1};
49
double matrix05[] = {1,0,0,1};
50
double matrix06[] = {1,0,0,1};
51
double matrix07[] = {1,0,0,1};
52
double matrix08[] = {1,0,0,1};
53
double matrix09[] = {1,0,0,1};
54
double matrix10[] = {1,0,0,1};
55
double matrix11[] = {1,0,0,1};
56
double matrix12[] = {1,0,0,1};
57
double matrix13[] = {1,0,0,1};
58
double matrix14[] = {1,0,0,1};
59
double matrix15[] = {1,0,0,1};
60
double matrix16[] = {1,0,0,1};
61
double matrix17[] = {1,0,0,1};
62
double matrix18[] = {1,0,0,1};
63
double matrix19[] = {1,0,0,1};
64
#define JC_NB_MATRICES 19
65
/* la matrice fixant le systeme de coordonnees "mathematiques" dans l'image */
66
double *matrices_pavage[] ={ matrix,
67
                                matrix01,matrix02,matrix03,matrix04,matrix05,matrix06,matrix07,matrix08,matrix09,
68
                                matrix10,matrix11,matrix12,matrix13,matrix14,matrix15,matrix16,matrix17,matrix18,matrix19
69
 
70
};
71
/** les vecteurs suivants sont initialises par la commande setvector numvector,u_1,u_2 */
72
/** ils sont remis a zero par resetvector numvector */
73
double vector[] = {0,0};
74
double vector01[] = {0,0};
75
double vector02[] = {0,0};
76
double vector03[] = {0,0};
77
double vector04[] = {0,0};
78
double vector05[] = {0,0};
79
double vector06[] = {0,0};
80
double vector07[] = {0,0};
81
double vector08[] = {0,0};
82
double vector09[] = {0,0};
83
double vector10[] = {0,0};
84
double vector11[] = {0,0};
85
double vector12[] = {0,0};
86
double vector13[] = {0,0};
87
double vector14[] = {0,0};
88
double vector15[] = {0,0};
89
double vector16[] = {0,0};
90
double vector17[] = {0,0};
91
double vector18[] = {0,0};
92
double vector19[] = {0,0};
93
 
94
double *vecteurs_pavage[] ={ vector,
95
                                vector01,vector02,vector03,vector04,vector05,vector06,vector07,vector08,vector09,
96
                                vector10,vector11,vector12,vector13,vector14,vector15,vector16,vector17,vector18,vector19
97
};
98
 
99
/** les coordonnees du parallelograme de pavage = coordonnees "mathematiques" du parallelogramme contenant l'image a recopier **/
100
/** on place ces coorodonnes avec setparallelogram xs,ys,xu,yu,xv,yu **/
101
/* xs,ys=coordonnees math du point 0,0,
102
 * xu,yu coordonnees math de l'horizontale
103
 * xv,yv coordonnees math de la verticale
104
 * ces coordonnees sont remises a leur valeur par defaut par resetparallelogram
105
 */
106
/** TODO serait-ce un moyen de definir la brush ?? **/
107
double parallogram_fonda[]={0,0,100,0,0,100};
108
 
109
/**** Fin modifs JC Fev 06 ******/
110
 
111
        /* Write the image */
112
void output(void)
113
{
114
    FILE *out;
115
 
116
    if(!image) return;
117
    if(imagefilename[0]) {
118
        out=fopen(imagefilename,"wb");
119
        if(out!=NULL) {gdImageGif(image,out); fclose(out); }
120
    }
121
    else gdImageGif(image,stdout);
122
    saved=1;
123
}
124
 
125
#include "lines.c"
126
#include "nametab.c"
127
#include "evalue.c"
128
#include "objects.c"
129
 
130
void process(void)
131
{
132
    char buf[MAX_LINELEN+1];
133
    int c;
134
    do {
135
        c=ggetline(buf); obj_main(buf);
136
    }
137
    while(c!=EOF);
138
}
139
 
140
int verify_tables(void) {
141
    return evaltab_verify();
142
}
143
 
144
int main(int argc, char *argv[])
145
{
146
    error1=error; error2=error; error3=error;
147
    substitute=substit;
148
    ev_varcnt=&varcnt; ev_var=vartab;
149
    if(argc==2 && strcasecmp(argv[1],"table")==0) {
150
        if(verify_tables()) {
151
            printf("Table disorder.\n"); return 1;
152
        }
153
        printf("Table orders OK.\n"); return 0;
154
    }
155
    vartab[0].name="animstep"; vartab[0].value=0;
156
    varcnt=1;
157
    if(argc>1) snprintf(imagefilename,sizeof(imagefilename),"%s",argv[1]);
158
    else imagefilename[0]=0;
159
    process();
160
    if(!saved || imagefilename[0]!=0) output();
161
    if(image) gdImageDestroy(image);
162
    return 0;
163
}
164