Rev 17578 | Rev 17585 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 17578 | Rev 17584 | ||
---|---|---|---|
Line 229... | Line 229... | ||
229 | myDashedLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
229 | myDashedLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
230 | else |
230 | else |
231 | gdImageLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
231 | gdImageLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
232 | if(tikz_file) |
232 | if(tikz_file) |
233 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
233 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
234 |
|
234 | tikz_options(pm->color[0],pm->fill),pm->p[0],flip(pm->p[1]),xx,flip(yy)); |
235 | if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
235 | if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
236 | } |
236 | } |
237 | 237 | ||
238 | /* Arrow */ |
238 | /* Arrow */ |
239 | void obj_arrow(objparm *pm) |
239 | void obj_arrow(objparm *pm) |
Line 333... | Line 333... | ||
333 | y1=min(pm->p[1],pm->p[3]); y2=max(pm->p[1],pm->p[3]); |
333 | y1=min(pm->p[1],pm->p[3]); y2=max(pm->p[1],pm->p[3]); |
334 | if(pm->fill) |
334 | if(pm->fill) |
335 | gdImageFilledRectangle(image,x1,y1,x2,y2,pm->color[0]); |
335 | gdImageFilledRectangle(image,x1,y1,x2,y2,pm->color[0]); |
336 | else |
336 | else |
337 | gdImageRectangle(image,x1,y1,x2,y2,pm->color[0]); |
337 | gdImageRectangle(image,x1,y1,x2,y2,pm->color[0]); |
338 | if(tikz_file) |
338 | if(tikz_file) |
339 |
|
339 | fprintf(tikz_file, |
340 |
|
340 | "\\draw\[%s] (%i,%i) rectangle (%i,%i);\n", |
341 |
|
341 | tikz_options(pm->color[0],pm->fill),x1,flip(y1),x2,flip(y2)); |
342 | } |
- | |
343 | if(vimg_enable) vimg_rect(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
342 | if(vimg_enable) vimg_rect(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
344 | } |
343 | } |
345 | 344 | ||
346 | /* square */ |
345 | /* square */ |
347 | void obj_square(objparm *pm) |
346 | void obj_square(objparm *pm) |
Line 379... | Line 378... | ||
379 | if(vimg_enable) vimg_polyline(scale_buf,3,1); |
378 | if(vimg_enable) vimg_polyline(scale_buf,3,1); |
380 | } |
379 | } |
381 | 380 | ||
382 | /* polygon */ |
381 | /* polygon */ |
383 | void obj_poly(objparm *pm) |
382 | void obj_poly(objparm *pm) |
384 | { |
383 | { |
385 | int cnt,i; |
384 | int cnt,i; |
386 | cnt=(pm->pcnt)/2; |
385 | cnt=(pm->pcnt)/2; |
387 | scale(pm->pd,pm->p,cnt); |
386 | scale(pm->pd,pm->p,cnt); |
388 | if(pm->fill) |
387 | if(pm->fill) |
389 | gdImageFilledPolygon(image,(gdPointPtr) pm->p,cnt,pm->color[0]); |
388 | gdImageFilledPolygon(image,(gdPointPtr) pm->p,cnt,pm->color[0]); |
Line 422... | Line 421... | ||
422 | if (tikz_file){ |
421 | if (tikz_file){ |
423 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
422 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
424 | tikz_options(pm->color[0],pm->fill),pm->p[0]+width2,flip(pm->p[1]+width2),pm->p[0]-width2,flip(pm->p[1]-width2)); |
423 | tikz_options(pm->color[0],pm->fill),pm->p[0]+width2,flip(pm->p[1]+width2),pm->p[0]-width2,flip(pm->p[1]-width2)); |
425 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
424 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i);\n", |
426 | tikz_options(pm->color[0],pm->fill),pm->p[0]-width2,flip(pm->p[1]+width2),pm->p[0]+width2,flip(pm->p[1]-width2)); |
425 | tikz_options(pm->color[0],pm->fill),pm->p[0]-width2,flip(pm->p[1]+width2),pm->p[0]+width2,flip(pm->p[1]-width2)); |
427 | } |
426 | } |
428 | } |
427 | } |
429 | /* crosshairs */ |
428 | /* crosshairs */ |
430 | 429 | ||
431 | void obj_crosshairs(objparm *pm) |
430 | void obj_crosshairs(objparm *pm) |
432 | { |
431 | { |
Line 941... | Line 940... | ||
941 | int dd; |
940 | int dd; |
942 | dd=pm->pd[0]; |
941 | dd=pm->pd[0]; |
943 | if(dd<3) dd=3; |
942 | if(dd<3) dd=3; |
944 | if(dd>MAX_SIZE) dd=MAX_SIZE; |
943 | if(dd>MAX_SIZE) dd=MAX_SIZE; |
945 | plotjump=dd; |
944 | plotjump=dd; |
946 | } |
945 | } |
947 | 946 | ||
948 | /* plot a curve, either parametric or explicit */ |
947 | /* plot a curve, either parametric or explicit */ |
949 | void _obj_plot(objparm *pm,int dash) |
948 | void _obj_plot(objparm *pm,int dash) |
950 | { |
949 | { |
951 | int i,j,n,dist,xx,yy,varpos; |
950 | int i,j,n,dist,xx,yy,varpos; |
952 | char p1[MAX_LINELEN+1], p2[MAX_LINELEN+1]; |
951 | char p1[MAX_LINELEN+1], p2[MAX_LINELEN+1]; |
Line 977... | Line 976... | ||
977 | for(i=j=0;i<=tstep;i++) { |
976 | for(i=j=0;i<=tstep;i++) { |
978 | if(n==1) { |
977 | if(n==1) { |
979 | if(tranged) t=tstart+i*v; else t=xstart+i*v; |
978 | if(tranged) t=tstart+i*v; else t=xstart+i*v; |
980 | eval_setval(varpos,t); dc[0]=t; dc[1]=strevalue(p1); |
979 | eval_setval(varpos,t); dc[0]=t; dc[1]=strevalue(p1); |
981 | } |
980 | } |
982 | else { |
981 | else { |
983 | t=tstart+i*v; eval_setval(varpos,t); |
982 | t=tstart+i*v; eval_setval(varpos,t); |
984 | dc[0]=strevalue(p1); dc[1]=strevalue(p2); |
983 | dc[0]=strevalue(p1); dc[1]=strevalue(p2); |
985 | } |
- | |
986 | if(!isfinite(dc[0]) || !isfinite(dc[1])) ic[0]=ic[1]=-BOUND; |
- | |
987 | else scale(dc,ic,1); |
- | |
988 | if(vimg_enable) vimg_plot1 (scale_buf[0],scale_buf[1]); |
- | |
989 | if(j==0) { |
- | |
990 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); j++; |
- | |
991 | } |
- | |
992 | else { |
- | |
993 | xx=ic[0]-oc[0]; yy=ic[1]-oc[1]; |
- | |
994 | dist=sqrt(xx*xx+yy*yy); |
- | |
995 | if(dist>0) { |
- | |
996 | if(dist>plotjump || dist==1) |
- | |
997 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); |
- | |
998 | else |
- | |
999 | if ( dash==1) |
- | |
1000 | gdImageDashedLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
- | |
1001 | else |
- | |
1002 | gdImageLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
- | |
1003 | } |
- | |
1004 | } |
984 | } |
- | 985 | if(!isfinite(dc[0]) || !isfinite(dc[1])) ic[0]=ic[1]=-BOUND; |
|
- | 986 | else scale(dc,ic,1); |
|
- | 987 | if(vimg_enable) vimg_plot1 (scale_buf[0],scale_buf[1]); |
|
- | 988 | if(j==0) { |
|
- | 989 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); j++; |
|
- | 990 | if (tikz_file) |
|
- | 991 | fprintf(tikz_file, |
|
- | 992 | "\\draw\[%s] (%i,%i) rectangle (%i,%i);\n", |
|
- | 993 | tikz_options(pm->color[0],1),ic[0],flip(ic[1]),ic[0]+1,flip(ic[1]+1)); |
|
- | 994 | } |
|
- | 995 | else { |
|
- | 996 | xx=ic[0]-oc[0]; yy=ic[1]-oc[1]; |
|
- | 997 | dist=sqrt(xx*xx+yy*yy); |
|
- | 998 | if(dist>0){ |
|
- | 999 | if(dist>plotjump || dist==1) { |
|
- | 1000 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); |
|
- | 1001 | if (tikz_file) |
|
- | 1002 | fprintf(tikz_file, |
|
- | 1003 | "\\draw\[%s] (%i,%i) rectangle (%i,%i);\n", |
|
- | 1004 | tikz_options(pm->color[0],1),ic[0],flip(ic[1]),ic[0]+1,flip(ic[1]+1)); |
|
- | 1005 | } |
|
- | 1006 | } |
|
- | 1007 | else { |
|
- | 1008 | if ( dash==1) |
|
- | 1009 | gdImageDashedLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
|
- | 1010 | else |
|
- | 1011 | gdImageLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
|
- | 1012 | if (tikz_file) |
|
- | 1013 | fprintf(tikz_file, |
|
- | 1014 | "\\draw\[%s] (%i,%i) -- (%i,%i);\n", |
|
- | 1015 | tikz_options(pm->color[0],dash),oc[0],flip(oc[1]),ic[0],flip(ic[1])); |
|
- | 1016 | ||
- | 1017 | } |
|
- | 1018 | } |
|
1005 | memmove(oc,ic,sizeof(oc)); |
1019 | memmove(oc,ic,sizeof(oc)); |
1006 | } |
1020 | } |
1007 | if(vimg_enable) vimg_plotend(); |
1021 | if(vimg_enable) vimg_plotend(); |
1008 | } |
1022 | } |
1009 | 1023 | ||
Line 1017... | Line 1031... | ||
1017 | dd=pm->pd[0]; |
1031 | dd=pm->pd[0]; |
1018 | if(dd<1) return; |
1032 | if(dd<1) return; |
1019 | if(dd>16) dd=16; |
1033 | if(dd>16) dd=16; |
1020 | lstep=dd; |
1034 | lstep=dd; |
1021 | } |
1035 | } |
1022 | 1036 | ||
1023 | /* level curve */ |
1037 | /* level curve */ |
1024 | void obj_levelcurve(objparm *pm) |
1038 | void obj_levelcurve(objparm *pm) |
1025 | { |
1039 | { |
1026 | char fn[MAX_LINELEN+1],tc[MAX_LINELEN+1]; |
1040 | char fn[MAX_LINELEN+1],tc[MAX_LINELEN+1]; |
1027 | int n,i; |
1041 | int n,i; |
Line 1047... | Line 1061... | ||
1047 | ld->levelcnt=n-1; |
1061 | ld->levelcnt=n-1; |
1048 | } |
1062 | } |
1049 | levelcurve(ld); |
1063 | levelcurve(ld); |
1050 | for(i=0;i<ld->datacnt;i++) { |
1064 | for(i=0;i<ld->datacnt;i++) { |
1051 | gdImageSetPixel(image,ld->xdata[i],ld->ydata[i],pm->color[0]); |
1065 | gdImageSetPixel(image,ld->xdata[i],ld->ydata[i],pm->color[0]); |
- | 1066 | if (tikz_file) |
|
- | 1067 | fprintf(tikz_file, |
|
- | 1068 | "\\draw\[%s] (%i,%i) rectangle (%i,%i);\n", |
|
- | 1069 | tikz_options(pm->color[0],1),ld->xdata[i],flip(ld->ydata[i]),ld->xdata[i]+1,flip(ld->ydata[i]+1)); |
|
1052 | } |
1070 | } |
1053 | free(ld); |
1071 | free(ld); |
1054 | } |
1072 | } |
1055 | 1073 | ||
1056 | /* set animation step */ |
1074 | /* set animation step */ |