Back to index

wims  3.65+svn20090927
flydraw.c
Go to the documentation of this file.
00001 /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017 
00018  /* This file is a temporary patch to tex eps files with extra borders.
00019   * It cuts the borders in the resulting gif file, so that the font
00020   * fits tightly in the cadre. libgd is required. */
00021 
00022 #include "flydraw.h"
00023 #include "../Lib/libwims.h"
00024 
00025 char imagefilename[1024];
00026 char vimgfilename[1024];
00027 int sizex, sizey, saved;
00028 gdImagePtr image=NULL, brushimg=NULL, tileimg=NULL, wimg=NULL;
00029 int brushed=0,tiled=0,styled=0,width=1, savew=1, wcolor=-1;
00030 int color_white,color_black,color_bounder;
00031 int linecnt=-100000;
00032 int tranged=0;
00033 double xscale=1,yscale=1,xstart=0,ystart=0;
00034 double tstart=0,tend=1,tstep=100,plotjump=200;
00035 double animstep=0;
00036 double matrix[]={1,0,0,1};  /* transformation matrix */
00037 int transform=0;            /* transformation indicator */
00038 double transx=0,transy=0;   /* translation vector */
00039 int lstep=4;
00040 ev_variable vartab[MAX_VARS];
00041 char varnamebuf[MAX_VARNAMEBUF], *varnameptr=varnamebuf;
00042 int varcnt;
00043 int vimg=0;                 /* 0: no vector image output.
00044                              * 1: DXF vector output. */
00045 int vimg_enable=0;          /* 0: disable. 1: enable. */
00046 int vimg_ready=0;
00047 FILE *vimgf=NULL;
00048 double scale_buf[MAX_PARMS];
00049 /***** Les modifs a JC Fev 06 *****/
00052 double matrix01[] = {1,0,0,1};
00053 double matrix02[] = {1,0,0,1};
00054 double matrix03[] = {1,0,0,1};
00055 double matrix04[] = {1,0,0,1};
00056 double matrix05[] = {1,0,0,1};
00057 double matrix06[] = {1,0,0,1};
00058 double matrix07[] = {1,0,0,1};
00059 double matrix08[] = {1,0,0,1};
00060 double matrix09[] = {1,0,0,1};
00061 double matrix10[] = {1,0,0,1};
00062 double matrix11[] = {1,0,0,1};
00063 double matrix12[] = {1,0,0,1};
00064 double matrix13[] = {1,0,0,1};
00065 double matrix14[] = {1,0,0,1};
00066 double matrix15[] = {1,0,0,1};
00067 double matrix16[] = {1,0,0,1};
00068 double matrix17[] = {1,0,0,1};
00069 double matrix18[] = {1,0,0,1};
00070 double matrix19[] = {1,0,0,1};
00071 #define JC_NB_MATRICES 19
00072 /* la matrice fixant le systeme de coordonnees "mathematiques" dans l'image */
00073 double *matrices_pavage[] ={ matrix, 
00074                             matrix01,matrix02,matrix03,matrix04,matrix05,matrix06,matrix07,matrix08,matrix09,
00075                             matrix10,matrix11,matrix12,matrix13,matrix14,matrix15,matrix16,matrix17,matrix18,matrix19
00076 
00077 }; 
00080 double vector[] = {0,0};
00081 double vector01[] = {0,0};
00082 double vector02[] = {0,0};
00083 double vector03[] = {0,0};
00084 double vector04[] = {0,0};
00085 double vector05[] = {0,0};
00086 double vector06[] = {0,0};
00087 double vector07[] = {0,0};
00088 double vector08[] = {0,0};
00089 double vector09[] = {0,0};
00090 double vector10[] = {0,0};
00091 double vector11[] = {0,0};
00092 double vector12[] = {0,0};
00093 double vector13[] = {0,0};
00094 double vector14[] = {0,0};
00095 double vector15[] = {0,0};
00096 double vector16[] = {0,0};
00097 double vector17[] = {0,0};
00098 double vector18[] = {0,0};
00099 double vector19[] = {0,0};
00100 
00101 double *vecteurs_pavage[] ={ vector, 
00102                             vector01,vector02,vector03,vector04,vector05,vector06,vector07,vector08,vector09,
00103                             vector10,vector11,vector12,vector13,vector14,vector15,vector16,vector17,vector18,vector19
00104 }; 
00105 
00108 /* xs,ys=coordonnees math du point 0,0, 
00109  * xu,yu coordonnees math de l'horizontale
00110  * xv,yv coordonnees math de la verticale
00111  * ces coordonnees sont remises a leur valeur par defaut par resetparallelogram
00112  */
00114 double parallogram_fonda[]={0,0,100,0,0,100};
00115 
00116 /**** Fin modifs JC Fev 06 ******/
00117 
00118        /* Write the image */
00119 void output(void)
00120 {
00121     FILE *out;
00122 
00123     if(!image) return;
00124     if(imagefilename[0]) {
00125        out=fopen(imagefilename,"wb");
00126        if(out!=NULL) {gdImageGif(image,out); fclose(out); }
00127     }
00128     else gdImageGif(image,stdout);
00129     saved=1;
00130 }
00131 
00132 #include "lines.c"
00133 #include "nametab.c"
00134 #include "evalue.c"
00135 #include "vimg.c"
00136 #include "objects.c"
00137 
00138 void process(void)
00139 {
00140     char buf[MAX_LINELEN+1];
00141     int c;
00142     do {
00143        c=ggetline(buf); obj_main(buf);
00144     }
00145     while(c!=EOF);
00146 }
00147 
00148 int verify_tables(void) {
00149     return evaltab_verify();
00150 }
00151 
00152 int main(int argc, char *argv[])
00153 {
00154     error1=error; error2=error; error3=error;
00155     substitute=substit;
00156     ev_varcnt=&varcnt; ev_var=vartab;
00157     if(argc==2 && strcasecmp(argv[1],"table")==0) {
00158        if(verify_tables()) {
00159            printf("Table disorder.\n"); return 1;
00160        }
00161        printf("Table orders OK.\n"); return 0;
00162     }
00163     vartab[0].name="animstep"; vartab[0].value=0;
00164     varcnt=1;
00165     if(argc>1) snprintf(imagefilename,sizeof(imagefilename),"%s",argv[1]);
00166     else imagefilename[0]=0;
00167     process();
00168     if(!saved || imagefilename[0]!=0) output();
00169     if(image) gdImageDestroy(image);
00170     if(vimg_ready) vimg_close();
00171     return 0;
00172 }
00173