Rev 6790 | Rev 7675 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6790 | Rev 7615 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | fclose(f); f=NULL; |
62 | fclose(f); f=NULL; |
63 | p1=getenv("TMPDIR"); if(p1==NULL || *p1==0) p1="."; |
63 | p1=getenv("TMPDIR"); if(p1==NULL || *p1==0) p1="."; |
64 | snprintf(tbuf,sizeof(tbuf),"%s/drawfile_.gif",p1); |
64 | snprintf(tbuf,sizeof(tbuf),"%s/drawfile_.gif",p1); |
65 | snprintf(sbuf,sizeof(sbuf),"convert %s %s",namebuf,tbuf); |
65 | snprintf(sbuf,sizeof(sbuf),"convert %s %s",namebuf,tbuf); |
66 | if (system(sbuf)) error("system_failed"); |
66 | if (system(sbuf)) error("system_failed"); |
67 | f=fopen(tbuf,"r"); |
67 | f=fopen(tbuf,"r"); |
68 | } |
68 | } |
69 | return f; |
69 | return f; |
70 | } |
70 | } |
71 | 71 | ||
72 | /* Does nothing; just a comment. */ |
72 | /* Does nothing; just a comment. */ |
Line 108... | Line 108... | ||
108 | /* new image */ |
108 | /* new image */ |
109 | void obj_existing(objparm *pm) |
109 | void obj_existing(objparm *pm) |
110 | { |
110 | { |
111 | FILE *inf; |
111 | FILE *inf; |
112 | char *pp; |
112 | char *pp; |
113 | 113 | ||
114 | if(image) { |
114 | if(image) { |
115 | gdImageDestroy(image);image=NULL; |
115 | gdImageDestroy(image);image=NULL; |
116 | } |
116 | } |
117 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
117 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
118 | inf=open4read(pp); |
118 | inf=open4read(pp); |
Line 137... | Line 137... | ||
137 | 137 | ||
138 | void _obj_arrow(objparm *pm, int twoside) |
138 | void _obj_arrow(objparm *pm, int twoside) |
139 | { |
139 | { |
140 | int l,ii[6],xx,yy; |
140 | int l,ii[6],xx,yy; |
141 | double dx,dy,length,dd[6]; |
141 | double dx,dy,length,dd[6]; |
142 | scale(pm->pd,pm->p,2); |
142 | scale(pm->pd,pm->p,2); |
143 | xx=ii[0]=pm->p[2];yy=ii[1]=pm->p[3]; |
143 | xx=ii[0]=pm->p[2];yy=ii[1]=pm->p[3]; |
144 | l=pm->pd[4];if(l<0) l=0; if(l>200) l=200; |
144 | l=pm->pd[4];if(l<0) l=0; if(l>200) l=200; |
145 | scale2(pm->pd[0]-pm->pd[2],pm->pd[1]-pm->pd[3],&dx,&dy); |
145 | scale2(pm->pd[0]-pm->pd[2],pm->pd[1]-pm->pd[3],&dx,&dy); |
146 | length=sqrt(dx*dx+dy*dy); |
146 | length=sqrt(dx*dx+dy*dy); |
147 | if(length<3 || l<5) goto stem; |
147 | if(length<3 || l<5) goto stem; |
Line 297... | Line 297... | ||
297 | void obj_lines(objparm *pm) |
297 | void obj_lines(objparm *pm) |
298 | { |
298 | { |
299 | int i, n; |
299 | int i, n; |
300 | n=(pm->pcnt)/2; |
300 | n=(pm->pcnt)/2; |
301 | scale(pm->pd,pm->p,n); |
301 | scale(pm->pd,pm->p,n); |
302 | for(i=2;i<2*n;i+=2) |
302 | for(i=2;i<2*n;i+=2) |
303 | gdImageLine(image,pm->p[i-2],pm->p[i-1],pm->p[i],pm->p[i+1],pm->color[0]); |
303 | gdImageLine(image,pm->p[i-2],pm->p[i-1],pm->p[i],pm->p[i+1],pm->color[0]); |
304 | if(vimg_enable) vimg_polyline(scale_buf,n,0); |
304 | if(vimg_enable) vimg_polyline(scale_buf,n,0); |
305 | } |
305 | } |
306 | 306 | ||
307 | /* segments */ |
307 | /* segments */ |
Line 323... | Line 323... | ||
323 | scale(pm->pd,pm->p,n); |
323 | scale(pm->pd,pm->p,n); |
324 | for(i=0;i<2*n;i+=2) |
324 | for(i=0;i<2*n;i+=2) |
325 | gdImageSetPixel(image,pm->p[i],pm->p[i+1],pm->color[0]); |
325 | gdImageSetPixel(image,pm->p[i],pm->p[i+1],pm->color[0]); |
326 | } |
326 | } |
327 | 327 | ||
328 | /* lattice. |
328 | /* lattice. |
329 | * x0,y0,xv1,yv1,xv2,yv2,n1,n2,color */ |
329 | * x0,y0,xv1,yv1,xv2,yv2,n1,n2,color */ |
330 | void obj_lattice(objparm *pm) |
330 | void obj_lattice(objparm *pm) |
331 | { |
331 | { |
332 | int n1,n2,i1,i2,xi1,yi1,xi2,yi2; |
332 | int n1,n2,i1,i2,xi1,yi1,xi2,yi2; |
333 | double xv1,xv2,yv1,yv2; |
333 | double xv1,xv2,yv1,yv2; |
Line 359... | Line 359... | ||
359 | /* Ellipse: centre 0,1, width 2, hight 3, color 4,5,6 */ |
359 | /* Ellipse: centre 0,1, width 2, hight 3, color 4,5,6 */ |
360 | void obj_ellipse(objparm *pm) |
360 | void obj_ellipse(objparm *pm) |
361 | { |
361 | { |
362 | scale(pm->pd,pm->p,1); |
362 | scale(pm->pd,pm->p,1); |
363 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
363 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
364 | if(pm->fill) { |
364 | if(pm->fill) { |
365 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
365 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
366 | color_bounder); |
366 | color_bounder); |
367 | gdImageFillToBorder(image,pm->p[0],pm->p[1], |
367 | gdImageFillToBorder(image,pm->p[0],pm->p[1], |
368 | color_bounder,pm->color[0]); |
368 | color_bounder,pm->color[0]); |
369 | } |
369 | } |
Line 379... | Line 379... | ||
379 | if(pm->fill) { |
379 | if(pm->fill) { |
380 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
380 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
381 | color_bounder); |
381 | color_bounder); |
382 | gdImageFillToBorder(image,pm->p[0],pm->p[1], |
382 | gdImageFillToBorder(image,pm->p[0],pm->p[1], |
383 | color_bounder,pm->color[0]); |
383 | color_bounder,pm->color[0]); |
384 | } |
384 | } |
385 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
385 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
386 | } |
386 | } |
387 | 387 | ||
388 | /* flood fill */ |
388 | /* flood fill */ |
389 | void obj_fill(objparm *pm) |
389 | void obj_fill(objparm *pm) |
Line 539... | Line 539... | ||
539 | if(*pe=='"') { |
539 | if(*pe=='"') { |
540 | p2=strchr(pe+1,'"'); |
540 | p2=strchr(pe+1,'"'); |
541 | if(p2 && *(p2+1)==0) {*p2=0; pe++;} |
541 | if(p2 && *(p2+1)==0) {*p2=0; pe++;} |
542 | } |
542 | } |
543 | if(pm->fill) |
543 | if(pm->fill) |
544 | gdImageStringUp(image,*(fonttab[i].fpt),pm->p[0],pm->p[1],pe, |
544 | gdImageStringUp(image,*(fonttab[i].fpt),pm->p[0],pm->p[1], (unsigned char*) pe, |
545 | pm->color[0]); |
545 | pm->color[0]); |
546 | else |
546 | else |
547 | gdImageString(image,*(fonttab[i].fpt),pm->p[0],pm->p[1],pe, |
547 | gdImageString(image,*(fonttab[i].fpt),pm->p[0],pm->p[1], (unsigned char*) pe, |
548 | pm->color[0]); |
548 | pm->color[0]); |
549 | } |
549 | } |
550 | 550 | ||
551 | /* point */ |
551 | /* point */ |
552 | void obj_point(objparm *pm) |
552 | void obj_point(objparm *pm) |
Line 559... | Line 559... | ||
559 | void obj_copy(objparm *pm) |
559 | void obj_copy(objparm *pm) |
560 | { |
560 | { |
561 | char *pp; |
561 | char *pp; |
562 | FILE *inf; |
562 | FILE *inf; |
563 | gdImagePtr insimg; |
563 | gdImagePtr insimg; |
564 | 564 | ||
565 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
565 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
566 | inf=open4read(pp); |
566 | inf=open4read(pp); |
567 | if(inf==NULL) { |
567 | if(inf==NULL) { |
568 | error("file_not_exist"); return; |
568 | error("file_not_exist"); return; |
569 | } |
569 | } |
570 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
570 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
571 | if(insimg==NULL) { |
571 | if(insimg==NULL) { |
572 | error("bad_gif"); return; |
572 | error("bad_gif"); return; |
573 | } |
573 | } |
574 | scale(pm->pd,pm->p,1); |
574 | scale(pm->pd,pm->p,1); |
575 | if(pm->pd[2]<0 && pm->pd[3]<0 && pm->pd[4]<0 && pm->pd[5]<0) |
575 | if(pm->pd[2]<0 && pm->pd[3]<0 && pm->pd[4]<0 && pm->pd[5]<0) |
576 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],0,0, |
576 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],0,0, |
577 | insimg->sx,insimg->sy); |
577 | insimg->sx,insimg->sy); |
578 | else |
578 | else |
579 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],pm->pd[2],pm->pd[3], |
579 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],pm->pd[2],pm->pd[3], |
580 | pm->pd[4]-pm->pd[2],pm->pd[5]-pm->pd[3]); |
580 | pm->pd[4]-pm->pd[2],pm->pd[5]-pm->pd[3]); |
581 | gdImageDestroy(insimg); |
581 | gdImageDestroy(insimg); |
582 | } |
582 | } |
583 | 583 | ||
584 | /* copy an image file, with resizing */ |
584 | /* copy an image file, with resizing */ |
585 | void obj_copyresize(objparm *pm) |
585 | void obj_copyresize(objparm *pm) |
586 | { |
586 | { |
587 | char *pp; |
587 | char *pp; |
588 | FILE *inf; |
588 | FILE *inf; |
589 | gdImagePtr insimg; |
589 | gdImagePtr insimg; |
590 | 590 | ||
591 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
591 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
592 | inf=open4read(pp); |
592 | inf=open4read(pp); |
593 | if(inf==NULL) { |
593 | if(inf==NULL) { |
594 | error("file_not_found"); return; |
594 | error("file_not_found"); return; |
595 | } |
595 | } |
596 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
596 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
597 | if(insimg==NULL) { |
597 | if(insimg==NULL) { |
598 | error("bad_gif"); return; |
598 | error("bad_gif"); return; |
599 | } |
599 | } |
600 | scale(pm->pd+4,pm->p+4,2); |
600 | scale(pm->pd+4,pm->p+4,2); |
601 | if(pm->pd[0]<0 && pm->pd[1]<0 && pm->pd[2]<0 && pm->pd[3]<0) |
601 | if(pm->pd[0]<0 && pm->pd[1]<0 && pm->pd[2]<0 && pm->pd[3]<0) |
602 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],0,0, |
602 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],0,0, |
603 | pm->p[6]-pm->p[4]+1,pm->p[7]-pm->p[5]+1, |
603 | pm->p[6]-pm->p[4]+1,pm->p[7]-pm->p[5]+1, |
604 | insimg->sx,insimg->sy); |
604 | insimg->sx,insimg->sy); |
605 | else |
605 | else |
606 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],pm->pd[0],pm->pd[1], |
606 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],pm->pd[0],pm->pd[1], |
Line 771... | Line 771... | ||
771 | if(varpos<0) return; /* unknown error */ |
771 | if(varpos<0) return; /* unknown error */ |
772 | evalue_compile(p1); evalue_compile(p2); |
772 | evalue_compile(p1); evalue_compile(p2); |
773 | if(vimg_enable) vimg_plotstart(); |
773 | if(vimg_enable) vimg_plotstart(); |
774 | for(i=j=0;i<=tstep;i++) { |
774 | for(i=j=0;i<=tstep;i++) { |
775 | if(n==1) { |
775 | if(n==1) { |
776 | if(tranged) t=tstart+i*v; else t=xstart+i*v; |
776 | if(tranged) t=tstart+i*v; else t=xstart+i*v; |
777 | eval_setval(varpos,t); dc[0]=t; dc[1]=evalue(p1); |
777 | eval_setval(varpos,t); dc[0]=t; dc[1]=evalue(p1); |
778 | } |
778 | } |
779 | else { |
779 | else { |
780 | t=tstart+i*v; eval_setval(varpos,t); |
780 | t=tstart+i*v; eval_setval(varpos,t); |
781 | dc[0]=evalue(p1); dc[1]=evalue(p2); |
781 | dc[0]=evalue(p1); dc[1]=evalue(p2); |
Line 795... | Line 795... | ||
795 | else |
795 | else |
796 | if ( dash==1) { |
796 | if ( dash==1) { |
797 | gdImageDashedLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
797 | gdImageDashedLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
798 | } else |
798 | } else |
799 | {gdImageLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); } |
799 | {gdImageLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); } |
800 | 800 | ||
801 | } |
801 | } |
802 | } |
802 | } |
803 | memmove(oc,ic,sizeof(oc)); |
803 | memmove(oc,ic,sizeof(oc)); |
804 | } |
804 | } |
805 | if(vimg_enable) vimg_plotend(); |
805 | if(vimg_enable) vimg_plotend(); |
806 | } |
806 | } |
807 | 807 | ||
808 | void obj_plot(objparm *pm) { _obj_plot( pm,0) ;} |
808 | void obj_plot(objparm *pm) { _obj_plot( pm,0) ;} |
809 | void obj_dplot(objparm *pm) { _obj_plot( pm,1) ; } |
809 | void obj_dplot(objparm *pm) { _obj_plot( pm,1) ; } |
810 | 810 | ||
811 | /* set levelcurve granularity */ |
811 | /* set levelcurve granularity */ |
812 | void obj_levelstep(objparm *pm) |
812 | void obj_levelstep(objparm *pm) |
813 | { |
813 | { |
814 | int dd; |
814 | int dd; |
815 | dd=pm->pd[0]; |
815 | dd=pm->pd[0]; |
816 | if(dd<1) return; if(dd>16) dd=16; |
816 | if(dd<1) return; if(dd>16) dd=16; |
817 | lstep=dd; |
817 | lstep=dd; |
818 | } |
818 | } |
Line 822... | Line 822... | ||
822 | { |
822 | { |
823 | char fn[MAX_LINELEN+1],tc[MAX_LINELEN+1]; |
823 | char fn[MAX_LINELEN+1],tc[MAX_LINELEN+1]; |
824 | int n,i; |
824 | int n,i; |
825 | double d; |
825 | double d; |
826 | leveldata *ld; |
826 | leveldata *ld; |
827 | 827 | ||
828 | ld=xmalloc(sizeof(leveldata)+16); |
828 | ld=xmalloc(sizeof(leveldata)+16); |
829 | ld->xname="x"; ld->yname="y"; |
829 | ld->xname="x"; ld->yname="y"; |
830 | ld->xsize=sizex; ld->ysize=sizey; ld->datacnt=0; |
830 | ld->xsize=sizex; ld->ysize=sizey; ld->datacnt=0; |
831 | ld->xrange[0]=xstart; ld->xrange[1]=sizex/xscale+xstart; |
831 | ld->xrange[0]=xstart; ld->xrange[1]=sizex/xscale+xstart; |
832 | ld->yrange[0]=sizey/yscale+ystart; ld->yrange[1]=ystart; |
832 | ld->yrange[0]=sizey/yscale+ystart; ld->yrange[1]=ystart; |
Line 953... | Line 953... | ||
953 | transx=transy=0; |
953 | transx=transy=0; |
954 | } |
954 | } |
955 | 955 | ||
956 | /***** Les modifs de Jean-Christophe Leger Fev 2006 *****/ |
956 | /***** Les modifs de Jean-Christophe Leger Fev 2006 *****/ |
957 | 957 | ||
958 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES, une liste de 4 nombres reels pour la matrice */ |
958 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES, une liste de 4 nombres reels pour la matrice */ |
959 | void obj_setmatrix(objparm *pm) |
959 | void obj_setmatrix(objparm *pm) |
960 | { |
960 | { |
961 | int nummatrix = (int) (pm->pd[0]); |
961 | int nummatrix = (int) (pm->pd[0]); |
962 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
962 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
963 | error("bad_matrix_number"); |
963 | error("bad_matrix_number"); |
Line 967... | Line 967... | ||
967 | matrices_pavage[nummatrix][1] = pm->pd[2]; |
967 | matrices_pavage[nummatrix][1] = pm->pd[2]; |
968 | matrices_pavage[nummatrix][2] = pm->pd[3]; |
968 | matrices_pavage[nummatrix][2] = pm->pd[3]; |
969 | matrices_pavage[nummatrix][3] = pm->pd[4]; |
969 | matrices_pavage[nummatrix][3] = pm->pd[4]; |
970 | } |
970 | } |
971 | 971 | ||
972 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
972 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
973 | void obj_resetmatrix(objparm *pm) |
973 | void obj_resetmatrix(objparm *pm) |
974 | { |
974 | { |
975 | int nummatrix = (int) (pm->pd[0]); |
975 | int nummatrix = (int) (pm->pd[0]); |
976 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
976 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
977 | error("bad_matrix_number"); |
977 | error("bad_matrix_number"); |
Line 981... | Line 981... | ||
981 | matrices_pavage[nummatrix][1] = 0; |
981 | matrices_pavage[nummatrix][1] = 0; |
982 | matrices_pavage[nummatrix][2] = 0; |
982 | matrices_pavage[nummatrix][2] = 0; |
983 | matrices_pavage[nummatrix][3] = 1; |
983 | matrices_pavage[nummatrix][3] = 1; |
984 | 984 | ||
985 | } |
985 | } |
986 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 2 nombres reels pour le vecteur */ |
986 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 2 nombres reels pour le vecteur */ |
987 | void obj_setvector(objparm *pm) |
987 | void obj_setvector(objparm *pm) |
988 | { |
988 | { |
989 | int nummatrix = (int) (pm->pd[0]); |
989 | int nummatrix = (int) (pm->pd[0]); |
990 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
990 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
991 | error("bad_vector_number"); |
991 | error("bad_vector_number"); |
Line 993... | Line 993... | ||
993 | } |
993 | } |
994 | vecteurs_pavage[nummatrix][0] = pm->pd[1]; |
994 | vecteurs_pavage[nummatrix][0] = pm->pd[1]; |
995 | vecteurs_pavage[nummatrix][1] = pm->pd[2]; |
995 | vecteurs_pavage[nummatrix][1] = pm->pd[2]; |
996 | } |
996 | } |
997 | 997 | ||
998 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
998 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
999 | void obj_resetvector(objparm *pm) |
999 | void obj_resetvector(objparm *pm) |
1000 | { |
1000 | { |
1001 | int nummatrix = (int) (pm->pd[0]); |
1001 | int nummatrix = (int) (pm->pd[0]); |
1002 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1002 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1003 | error("bad_vector_number"); |
1003 | error("bad_vector_number"); |
Line 1005... | Line 1005... | ||
1005 | } |
1005 | } |
1006 | vecteurs_pavage[nummatrix][0] = 0; |
1006 | vecteurs_pavage[nummatrix][0] = 0; |
1007 | vecteurs_pavage[nummatrix][1] = 0; |
1007 | vecteurs_pavage[nummatrix][1] = 0; |
1008 | } |
1008 | } |
1009 | 1009 | ||
1010 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 6 nombres reels pour la matrice et le vecteur */ |
1010 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 6 nombres reels pour la matrice et le vecteur */ |
1011 | void obj_settransform(objparm *pm) |
1011 | void obj_settransform(objparm *pm) |
1012 | { |
1012 | { |
1013 | int nummatrix = (int) (pm->pd[0]); |
1013 | int nummatrix = (int) (pm->pd[0]); |
1014 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1014 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1015 | error("bad_vector_number"); |
1015 | error("bad_vector_number"); |
Line 1022... | Line 1022... | ||
1022 | vecteurs_pavage[nummatrix][0] = pm->pd[5]; |
1022 | vecteurs_pavage[nummatrix][0] = pm->pd[5]; |
1023 | vecteurs_pavage[nummatrix][1] = pm->pd[6]; |
1023 | vecteurs_pavage[nummatrix][1] = pm->pd[6]; |
1024 | } |
1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
1027 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
1028 | void obj_resettransform(objparm *pm) |
1028 | void obj_resettransform(objparm *pm) |
1029 | { |
1029 | { |
1030 | int nummatrix = (int) (pm->pd[0]); |
1030 | int nummatrix = (int) (pm->pd[0]); |
1031 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1031 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
1032 | error("bad_vector_number"); |
1032 | error("bad_vector_number"); |
Line 1038... | Line 1038... | ||
1038 | matrices_pavage[nummatrix][1] = 0; |
1038 | matrices_pavage[nummatrix][1] = 0; |
1039 | matrices_pavage[nummatrix][2] = 0; |
1039 | matrices_pavage[nummatrix][2] = 0; |
1040 | matrices_pavage[nummatrix][3] = 1; |
1040 | matrices_pavage[nummatrix][3] = 1; |
1041 | } |
1041 | } |
1042 | 1042 | ||
1043 | /* arguments: une liste de 6 nombres reels pour les coordonnees de l'origine et des vecteurs de base */ |
1043 | /* arguments: une liste de 6 nombres reels pour les coordonnees de l'origine et des vecteurs de base */ |
1044 | void obj_setparallelogram(objparm *pm) |
1044 | void obj_setparallelogram(objparm *pm) |
1045 | { |
1045 | { |
1046 | int i; |
1046 | int i; |
1047 | for(i=0;i<6;i++) parallogram_fonda[i]=pm->pd[i]; |
1047 | for(i=0;i<6;i++) parallogram_fonda[i]=pm->pd[i]; |
1048 | } |
1048 | } |
Line 1074... | Line 1074... | ||
1074 | int pti[2]; /* les coordonnees img du point a placer sur le canevas */ |
1074 | int pti[2]; /* les coordonnees img du point a placer sur le canevas */ |
1075 | int t; |
1075 | int t; |
1076 | /* gestion palette de couleur de l'image a inserer */ |
1076 | /* gestion palette de couleur de l'image a inserer */ |
1077 | int colorMap[gdMaxColors]; |
1077 | int colorMap[gdMaxColors]; |
1078 | int comptmat=0; /* combien de matrices en tout ? */ |
1078 | int comptmat=0; /* combien de matrices en tout ? */ |
1079 | 1079 | ||
1080 | for (i=0; (i<gdMaxColors); i++) { |
1080 | for (i=0; (i<gdMaxColors); i++) { |
1081 | colorMap[i] = (-1); |
1081 | colorMap[i] = (-1); |
1082 | } |
1082 | } |
1083 | 1083 | ||
1084 | /* Gestion des parametres la liste est censee finir avec le nom du fichier */ |
1084 | /* Gestion des parametres la liste est censee finir avec le nom du fichier */ |
1085 | t=pm->pcnt-1; /* il faut enlever le nom de fichier ! c'est le nombre de parametres en plus */ |
1085 | t=pm->pcnt-1; /* il faut enlever le nom de fichier ! c'est le nombre de parametres en plus */ |
1086 | pp=find_word_start(pm->str); |
1086 | pp=find_word_start(pm->str); |
1087 | /* visiblement find_word_start n'arrive pas a trouver le dernier mot dans un contexte ou le nombre de parameters est variable |
1087 | /* visiblement find_word_start n'arrive pas a trouver le dernier mot dans un contexte ou le nombre de parameters est variable |
1088 | * on cherche donc l'emplacement de la derniere virgule: |
1088 | * on cherche donc l'emplacement de la derniere virgule: |
1089 | * il y en a une car t>0, on retrouve ensuite le debut de mot |
1089 | * il y en a une car t>0, on retrouve ensuite le debut de mot |
1090 | */ |
1090 | */ |
Line 1104... | Line 1104... | ||
1104 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
1104 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
1105 | if(insimg==NULL) { |
1105 | if(insimg==NULL) { |
1106 | error("bad_gif"); return; |
1106 | error("bad_gif"); return; |
1107 | } |
1107 | } |
1108 | 1108 | ||
1109 | /* On recupere les numeros des matrices/vecteurs a faire agir, |
1109 | /* On recupere les numeros des matrices/vecteurs a faire agir, |
1110 | * s'il n'y en a pas, on les fait toutes agir |
1110 | * s'il n'y en a pas, on les fait toutes agir |
1111 | */ |
1111 | */ |
1112 | for(i=0;i<t && i< JC_NB_MATRICES;i++) { |
1112 | for(i=0;i<t && i< JC_NB_MATRICES;i++) { |
1113 | if(pm->pd[i]>=1 && pm->pd[i]<=JC_NB_MATRICES){ |
1113 | if(pm->pd[i]>=1 && pm->pd[i]<=JC_NB_MATRICES){ |
1114 | nummatrices[comptmat] = pm->pd[i]; |
1114 | nummatrices[comptmat] = pm->pd[i]; |
1115 | comptmat++; |
1115 | comptmat++; |
Line 1119... | Line 1119... | ||
1119 | for(i=0;i<JC_NB_MATRICES;i++) { |
1119 | for(i=0;i<JC_NB_MATRICES;i++) { |
1120 | nummatrices[i] = i+1; |
1120 | nummatrices[i] = i+1; |
1121 | } |
1121 | } |
1122 | comptmat=JC_NB_MATRICES; |
1122 | comptmat=JC_NB_MATRICES; |
1123 | } |
1123 | } |
1124 | 1124 | ||
1125 | 1125 | ||
1126 | imax = gdImageSX(insimg); |
1126 | imax = gdImageSX(insimg); |
1127 | jmax = gdImageSY(insimg); |
1127 | jmax = gdImageSY(insimg); |
1128 | 1128 | ||
1129 | for(i=0;i<imax;i++){ |
1129 | for(i=0;i<imax;i++){ |
Line 1135... | Line 1135... | ||
1135 | /* Have we established a mapping for this color? */ |
1135 | /* Have we established a mapping for this color? */ |
1136 | if (colorMap[c] == (-1)) { |
1136 | if (colorMap[c] == (-1)) { |
1137 | /* If it's the same image, mapping is trivial, dans notre cas ca n'arrive jamais... */ |
1137 | /* If it's the same image, mapping is trivial, dans notre cas ca n'arrive jamais... */ |
1138 | if (image == insimg) { |
1138 | if (image == insimg) { |
1139 | nc = c; |
1139 | nc = c; |
1140 | } else { |
1140 | } else { |
1141 | /* First look for an exact match */ |
1141 | /* First look for an exact match */ |
1142 | nc = gdImageColorExact(image, |
1142 | nc = gdImageColorExact(image, |
1143 | insimg->red[c], insimg->green[c], |
1143 | insimg->red[c], insimg->green[c], |
1144 | insimg->blue[c]); |
1144 | insimg->blue[c]); |
1145 | } |
1145 | } |
1146 | if (nc == (-1)) { |
1146 | if (nc == (-1)) { |
1147 | /* No, so try to allocate it */ |
1147 | /* No, so try to allocate it */ |
1148 | nc = gdImageColorAllocate(image, |
1148 | nc = gdImageColorAllocate(image, |
1149 | insimg->red[c], insimg->green[c], |
1149 | insimg->red[c], insimg->green[c], |
1150 | insimg->blue[c]); |
1150 | insimg->blue[c]); |
Line 1207... | Line 1207... | ||
1207 | int parse_parms(char *p,objparm *pm,struct objtab *o) |
1207 | int parse_parms(char *p,objparm *pm,struct objtab *o) |
1208 | { |
1208 | { |
1209 | char buf[MAX_LINELEN+1]; |
1209 | char buf[MAX_LINELEN+1]; |
1210 | char *p1, *p2; |
1210 | char *p1, *p2; |
1211 | int j,t,c,c1,c2; |
1211 | int j,t,c,c1,c2; |
1212 | 1212 | ||
1213 | c=o->color_pos;c1=c2=0; |
1213 | c=o->color_pos;c1=c2=0; |
1214 | pm->color[0]=pm->color[1]=0; |
1214 | pm->color[0]=pm->color[1]=0; |
1215 | if(c>0) c1=c; if(c<0) c2=-c; c=c1+c2; |
1215 | if(c>0) c1=c; if(c<0) c2=-c; c=c1+c2; |
1216 | t=itemnum(p);if(t<o->required_parms+3*c) return -1; |
1216 | t=itemnum(p);if(t<o->required_parms+3*c) return -1; |
1217 | if(c1>0 && t>o->required_parms+3*c) t=o->required_parms+3*c; |
1217 | if(c1>0 && t>o->required_parms+3*c) t=o->required_parms+3*c; |