Rev 18301 | Rev 18317 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18301 | Rev 18308 | ||
---|---|---|---|
Line 708... | Line 708... | ||
708 | } |
708 | } |
709 | 709 | ||
710 | /* arc */ |
710 | /* arc */ |
711 | void obj_arc(objparm *pm) |
711 | void obj_arc(objparm *pm) |
712 | { |
712 | { |
- | 713 | const double DEG=M_PI/180; |
|
- | 714 | int i,nb; |
|
- | 715 | double dt,rx=pm->pd[2]*xscale/2, ry=pm->pd[3]*yscale/2, r=rx>ry?rx:ry, |
|
- | 716 | t1=pm->pd[4]*DEG, t2=pm->pd[5]*DEG; |
|
713 | scale(pm->pd,pm->p,1); |
717 | scale(pm->pd,pm->p,1); |
- | 718 | t2-=t1; |
|
- | 719 | t2-=2*M_PI*floor(t2/(2*M_PI)); |
|
- | 720 | nb = r*t2/3; |
|
- | 721 | dt = t2/nb; |
|
714 |
|
722 | /* trouble with gdImageArc as the angles are of type int |
715 | gdImageArc |
723 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3], |
716 |
|
724 | rint(pm->pd[4]),rint(pm->pd[5]),pm->color[0]); */ |
- | 725 | for (i=0; i<nb; ++i,t1+=dt) |
|
- | 726 | gdImageLine(image,pm->p[0]+rx*cos(t1),pm->p[1]+ry*sin(t1), |
|
- | 727 | pm->p[0]+rx*cos(t1+dt),pm->p[1]+ry*sin(t1+dt),pm->color[0]); |
|
717 | if(tikz_file) { |
728 | if(tikz_file) { |
718 | pm->pd[4]-=360*rint(pm->pd[4]/360); |
- | |
719 | pm->pd[5]-=360*rint(pm->pd[5]/360); |
- | |
720 | if(pm->pd[4]>pm->pd[5]) pm->pd[5]+=360; |
- | |
721 | fprintf(tikz_file, |
729 | fprintf(tikz_file, |
722 | "\\draw\[%s, domain=%f:%f] plot ({%i+%f*cos(\\x)}, {%i+%f*sin(\\x)});\n", |
730 | "\\draw\[%s, domain=%f:%f] plot ({%i+%f*cos(\\x)}, {%i+%f*sin(\\x)});\n", |
723 | tikz_options(pm->color[0],pm->fill), |
731 | tikz_options(pm->color[0],pm->fill), |
724 | pm->pd[4], |
732 | pm->pd[4],t1/DEG,pm->p[0],rx,flip(pm->p[1]),-ry); |
725 | } |
733 | } |
726 | /*FIXME echelle mauvaise*/ |
734 | /*FIXME echelle mauvaise*/ |
727 | if(vimg_enable) vimg_arc(scale_buf[0],scale_buf[1], |
735 | if(vimg_enable) vimg_arc(scale_buf[0],scale_buf[1], |
728 | 0.5*pm->pd[2],0.5*pm->pd[3],pm->pd[4],pm->pd[5]); |
736 | 0.5*pm->pd[2],0.5*pm->pd[3],pm->pd[4],pm->pd[5]); |
729 | } |
737 | } |
Line 740... | Line 748... | ||
740 | dpts[4]=pm->pd[0]+pm->pd[2]*cos(DEG*pm->pd[4]); |
748 | dpts[4]=pm->pd[0]+pm->pd[2]*cos(DEG*pm->pd[4]); |
741 | dpts[5]=pm->pd[1]+pm->pd[2]*sin(DEG*pm->pd[4]); |
749 | dpts[5]=pm->pd[1]+pm->pd[2]*sin(DEG*pm->pd[4]); |
742 | scale(dpts, pts, 3); |
750 | scale(dpts, pts, 3); |
743 | gdImageLine(image,pts[0],pts[1],pts[2],pts[3],pm->color[0]); |
751 | gdImageLine(image,pts[0],pts[1],pts[2],pts[3],pm->color[0]); |
744 | gdImageLine(image,pts[0],pts[1],pts[4],pts[5],pm->color[0]); |
752 | gdImageLine(image,pts[0],pts[1],pts[4],pts[5],pm->color[0]); |
745 | gdImageArc(image,pts[0],pts[1],wx,wy, |
753 | gdImageArc(image,pts[0],pts[1],wx,wy,pm->pd[3],pm->pd[4],pm->color[0]); |
746 | if(tikz_file) { |
754 | if(tikz_file) { |
747 | fprintf(tikz_file, "\\draw\[%s, domain=%f:%f] plot ({%i+%f*cos(\\x)}, {%i+%f*sin(\\x)});\n", |
755 | fprintf(tikz_file, "\\draw\[%s, domain=%f:%f] plot ({%i+%f*cos(\\x)}, {%i+%f*sin(\\x)});\n", |
748 | tikz_options(pm->color[0],pm->fill),pm->pd[3],pm->pd[4],pts[0],wx*0.5,flip(pts[1]),wy*(-0.5)); |
756 | tikz_options(pm->color[0],pm->fill),pm->pd[3],pm->pd[4],pts[0],wx*0.5,flip(pts[1]),wy*(-0.5)); |
749 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i) (%i, %i) -- (%i, %i);\n", |
757 | fprintf(tikz_file, "\\draw\[%s] (%i, %i) -- (%i, %i) (%i, %i) -- (%i, %i);\n", |
750 | tikz_options(pm->color[0],pm->fill),pts[0],flip(pts[1]),pts[2],flip(pts[3]),pts[0],flip(pts[1]),pts[4],flip(pts[5])); |
758 | tikz_options(pm->color[0],pm->fill),pts[0],flip(pts[1]),pts[2],flip(pts[3]),pts[0],flip(pts[1]),pts[4],flip(pts[5])); |