cvs: pecl /gdchart/gdchart-src gdc.h gdc_pie.c gdchart.c
| From: | Rasmus Lerdorf | Date: | Fri, 29 Aug 2003 22:56:50 +0000 |
| Subject: | cvs: pecl /gdchart/gdchart-src gdc.h gdc_pie.c gdchart.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-432@lists.php.net to get a copy of this message | ||
rasmus Fri Aug 29 18:56:50 2003 EDT
Modified files:
/pecl/gdchart/gdchart-src gdc.h gdc_pie.c gdchart.c
Log:
- Fix annoying rounding errors in backend gdchart code
- Switch to using the native FilledArc code
- Turn on anti-aliasing everywhere
Index: pecl/gdchart/gdchart-src/gdc.h diff -u pecl/gdchart/gdchart-src/gdc.h:1.2 pecl/gdchart/gdchart-src/gdc.h:1.3 --- pecl/gdchart/gdchart-src/gdc.h:1.2 Wed Aug 27 05:51:56 2003 +++ pecl/gdchart/gdchart-src/gdc.h Fri Aug 29 18:56:50 2003 @@ -20,6 +20,7 @@ #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #endif +#define FUZZ 0.0001 #include <limits.h> #include <float.h> Index: pecl/gdchart/gdchart-src/gdc_pie.c diff -u pecl/gdchart/gdchart-src/gdc_pie.c:1.2 pecl/gdchart/gdchart-src/gdc_pie.c:1.3 --- pecl/gdchart/gdchart-src/gdc_pie.c:1.2 Wed Aug 27 05:51:56 2003 +++ pecl/gdchart/gdchart-src/gdc_pie.c Fri Aug 29 18:56:50 2003 @@ -386,6 +386,7 @@ #if HAVE_LIBGD204 im = gdImageCreateTrueColor( IMGWIDTH, IMGHEIGHT ); gdImageFilledRectangle(im,0,0, IMGWIDTH-1,IMGHEIGHT-1, GDCPIE_BGColor); + gdImageAntialias(im, 1); #else im = gdImageCreate( IMGWIDTH, IMGHEIGHT ); #endif @@ -440,15 +441,23 @@ { int edge_color = GDCPIE_EdgeColor == GDC_NOCOLOR? SliceColorShd[i]: EdgeColorShd; - +#if 0 gdImageLine( im, CX(i,1), CY(i,1), IX(i,1,1), IY(i,1,1), edge_color ); gdImageLine( im, CX(i,1), CY(i,1), IX(i,2,1), IY(i,2,1), edge_color ); - gdImageArc( im, CX(i,1), CY(i,1), +#endif + gdImageFilledArc( im, CX(i,1), CY(i,1), + (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), + TO_INT_DEG_FLOOR(slice_angle[1][i])+270, + TO_INT_DEG_FLOOR(slice_angle[2][i])+270, + SliceColorShd[i], gdPie ); + if(edge_color!=GDC_NOCOLOR) { + gdImageSetAntiAliased(im, edge_color); + gdImageFilledArc( im, CX(i,1), CY(i,1), (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), TO_INT_DEG_FLOOR(slice_angle[1][i])+270, - TO_INT_DEG_CEIL(slice_angle[2][i])+270, - edge_color ); - + TO_INT_DEG_FLOOR(slice_angle[2][i])+270, + gdAntiAliased, gdNoFill|gdEdged ); + } /* gdImageFilledArc( im, CX(i,1), CY(i,1), */ /* rad*ellipsex*2, rad*ellipsey*2, */ /* TO_INT_DEG_FLOOR(slice_angle[1][i])+270, */ @@ -456,11 +465,13 @@ /* SliceColorShd[i], */ /* gdPie ); */ /* attempt to fill, if slice is wide enough */ +#if 0 if( (ABS(IX(i,1,1)-IX(i,2,1)) + ABS(IY(i,1,1)-IY(i,2,1))) > 2 ) { float rad = rad1; /* local override */ gdImageFillToBorder( im, IX(i,0,1), IY(i,0,1), edge_color, SliceColorShd[i] ); } +#endif } } /* fill in connection to foreground pie */ @@ -479,14 +490,14 @@ tmp_slice[num_slice_angles].hidden = TRUE; tmp_slice[num_slice_angles].i = i; tmp_slice[num_slice_angles].slice = slice_angle[0][i]; - tmp_slice[num_slice_angles++].angle = slice_angle[1][i]; + tmp_slice[num_slice_angles++].angle = slice_angle[1][i]-0.01; if( RAD_DIST1(slice_angle[2][i]) < RAD_DIST2(slice_angle[0][i]) ) tmp_slice[num_slice_angles].hidden = FALSE; else tmp_slice[num_slice_angles].hidden = TRUE; tmp_slice[num_slice_angles].i = i; tmp_slice[num_slice_angles].slice = slice_angle[0][i]; - tmp_slice[num_slice_angles++].angle = slice_angle[2][i]; + tmp_slice[num_slice_angles++].angle = slice_angle[2][i]-0.01; /* identify which 2 slices (i) have a tangent parallel to depth angle */ if( slice_angle[1][i]<MOD_2PI(pie_3D_rad+M_PI_2) && slice_angle[2][i]>MOD_2PI(pie_3D_rad+M_PI_2) ) { @@ -521,18 +532,17 @@ else { rad -= 2.0; /* no peeking */ - gdp[0].x = OX(i,slice_angle[0][i],0); gdp[0].y = OY(i,slice_angle[0][i],0); - gdp[1].x = OX(i,slice_angle[0][i],1); gdp[1].y = OY(i,slice_angle[0][i],1); + gdp[0].x = OX(i,slice_angle[0][i]-0.011,0); gdp[0].y = OY(i,slice_angle[0][i]-0.011,0); + gdp[1].x = OX(i,slice_angle[0][i]-0.011,1); gdp[1].y = OY(i,slice_angle[0][i]-0.011,1); rad += 2.0; - gdp[2].x = OX(i,slice_angle[1][i],1); gdp[2].y = OY(i,slice_angle[1][i],1); - gdp[3].x = OX(i,slice_angle[1][i],0); gdp[3].y = OY(i,slice_angle[1][i],0); - gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i] ); - gdp[2].x = OX(i,slice_angle[2][i],1); gdp[2].y = OY(i,slice_angle[2][i],1); - gdp[3].x = OX(i,slice_angle[2][i],0); gdp[3].y = OY(i,slice_angle[2][i],0); + gdp[2].x = OX(i,slice_angle[1][i]-0.011,1); gdp[2].y = OY(i,slice_angle[1][i]-0.011,1); + gdp[3].x = OX(i,slice_angle[1][i]-0.011,0); gdp[3].y = OY(i,slice_angle[1][i]-0.011,0); + gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i]); + gdp[2].x = OX(i,slice_angle[2][i]-0.011,1); gdp[2].y = OY(i,slice_angle[2][i]-0.011,1); + gdp[3].x = OX(i,slice_angle[2][i]-0.011,0); gdp[3].y = OY(i,slice_angle[2][i]-0.011,0); gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i] ); } - if( GDCPIE_EdgeColor != GDC_NOCOLOR ) { gdImageLine( im, CX(i,0), CY(i,0), CX(i,1), CY(i,1), EdgeColorShd ); @@ -558,13 +568,23 @@ EdgeColorShd; /* last += val[i]; */ /* EXPLODE_CX_CY( slice_angle[0][i], i ); */ +#if 0 gdImageLine( im, CX(i,0), CY(i,0), IX(i,1,0), IY(i,1,0), edge_color ); gdImageLine( im, CX(i,0), CY(i,0), IX(i,2,0), IY(i,2,0), edge_color ); - gdImageArc( im, CX(i,0), CY(i,0), +#endif + gdImageFilledArc( im, CX(i,0), CY(i,0), + (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), + (TO_INT_DEG_FLOOR(slice_angle[1][i])+270)%360, + (TO_INT_DEG_FLOOR(slice_angle[2][i])+270)%360, + SliceColor[i], gdPie ); + if(edge_color!=GDC_NOCOLOR) { + gdImageSetAntiAliased(im, edge_color); + gdImageFilledArc( im, CX(i,0), CY(i,0), (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), (TO_INT_DEG_FLOOR(slice_angle[1][i])+270)%360, - (TO_INT_DEG_CEIL(slice_angle[2][i])+270)%360, - edge_color ); + (TO_INT_DEG_FLOOR(slice_angle[2][i])+270)%360, + gdAntiAliased, gdNoFill|gdEdged ); + } /* antialiasing here */ /* likely only on the face? */ /* bugs in gd2.0.0 */ @@ -579,6 +599,7 @@ /* SliceColor[i], */ /* gdPie ); */ /* attempt to fill, if slice is wide enough */ +#if 0 { float rad = rad1; /* local override */ if( (ABS(IX(i,1,1)-IX(i,2,1)) + ABS(IY(i,1,1)-IY(i,2,1))) > 2 ) @@ -588,6 +609,7 @@ /* catch missed pixels on narrow slices */ gdImageLine( im, CX(i,0), CY(i,0), IX(i,0,0), IY(i,0,0), SliceColor[i] ); } +#endif } } Index: pecl/gdchart/gdchart-src/gdchart.c diff -u pecl/gdchart/gdchart-src/gdchart.c:1.4 pecl/gdchart/gdchart-src/gdchart.c:1.5 --- pecl/gdchart/gdchart-src/gdchart.c:1.4 Wed Aug 27 18:49:11 2003 +++ pecl/gdchart/gdchart-src/gdchart.c Fri Aug 29 18:56:50 2003 @@ -18,14 +18,16 @@ #include "gdchart.h" #include "ext/standard/php_image.h" +#define gdImageLine gdImageAALine + #define HIGHSET 0 #define LOWSET 1 #define CLOSESET 2 /* scaled translation onto graph */ -#define PX( x ) (int)( xorig + (setno*xdepth_3D) + (x)*xscl ) -#define PY( y ) (int)( yorig - (setno*ydepth_3D) + (y)*yscl ) -#define PV( y ) (int)( vyorig - (setno*ydepth_3D) + (y)*vyscl ) +#define PX( x ) (int)( xorig + (setno*xdepth_3D) + (x)*xscl + FUZZ ) +#define PY( y ) (int)( yorig - (setno*ydepth_3D) + (y)*yscl + FUZZ ) +#define PV( y ) (int)( vyorig - (setno*ydepth_3D) + (y)*vyscl + FUZZ ) #define SET_RECT( gdp, x1, x2, y1, y2 ) gdp[0].x = gdp[3].x = x1, \ gdp[0].y = gdp[1].y = y1, \ @@ -61,7 +63,7 @@ int clr[], int clrshd[] ) { -#define F(x,i) (int)( (float)((x)-x1)*slope[i]+(float)y1[i] ) +#define F(x,i) (int)( FUZZ + (float)((x)-x1)*slope[i]+(float)y1[i] ) float depth_slope = xdepth==0? FLT_MAX: (float)ydepth/(float)xdepth; CREATE_ARRAY1( slope, float, num_sets ); /* float slope[num_sets] */ CREATE_ARRAY1( lnclr, int, num_sets ); /* int slope[num_sets] */ @@ -134,7 +136,7 @@ y_intercept = (y1 > y0 && y2 < y0) || /* line crosses y0 */ (y1 < y0 && y2 > y0)? - (int)((1.0/ABS(line_slope))*(float)(ABS(y1-y0)))+x1: + (int)(FUZZ + (1.0/ABS(line_slope))*(float)(ABS(y1-y0)))+x1: 0; /* never */ /* edging along y0 depth */ @@ -708,8 +710,8 @@ #define HYP_DEPTH ( (double)((IMGWIDTH+IMGHEIGHT)/2) * ((double)GDC_3d_depth)/100.0 ) #define RAD_DEPTH ( (double)GDC_3d_angle*2*M_PI/360 ) - xdepth_3D = threeD? (int)( cos(RAD_DEPTH) * HYP_DEPTH ): 0; - ydepth_3D = threeD? (int)( sin(RAD_DEPTH) * HYP_DEPTH ): 0; + xdepth_3D = threeD? (int)( FUZZ + cos(RAD_DEPTH) * HYP_DEPTH ): 0; + ydepth_3D = threeD? (int)( FUZZ + sin(RAD_DEPTH) * HYP_DEPTH ): 0; xdepth_3Dtotal = xdepth_3D*set_depth; ydepth_3Dtotal = ydepth_3D*set_depth; annote_hgt = GDC_annotation && *(GDC_annotation->note)? @@ -770,8 +772,8 @@ } else /* length & width due to the angle */ { - len = (int)( (double)lftsz.w * sin_xangle + (double)lftsz.h * cos_xangle ); - wdth = (int)( (double)lftsz.h / sin_xangle ); + len = (int)( FUZZ + (double)lftsz.w * sin_xangle + (double)lftsz.h * cos_xangle ); + wdth = (int)( FUZZ + (double)lftsz.h / sin_xangle ); } } biggest = MAX( len, biggest ); /* last seg */ @@ -851,7 +853,7 @@ /* lowest = (lowest-ypoints[0]) - */ /* ( ( ((lowest-ypoints[0])/ylbl_interval)*ylbl_interval ) - */ /* ( (float)((int)((lowest-ypoints[0])/ylbl_interval))*ylbl_interval ) ); */ - lowest = ylbl_interval * (float)(int)((lowest-ypoints[0])/ylbl_interval); + lowest = ylbl_interval * (float)(int)(FUZZ + (lowest-ypoints[0])/ylbl_interval); } /* find smallest interval-point > highest */ tmp_highest = lowest; @@ -942,8 +944,8 @@ /*???? yorig = GDC_hard_yorig; FRED - check email */ GDC_hard_yorig = yorig; - hlf_barwdth = (int)( (float)(PX(2)-PX(1)) * (((float)GDC_bar_width/100.0)/2.0) ); /* used only for bars */ - hlf_hlccapwdth = (int)( (float)(PX(2)-PX(1)) * (((float)GDC_HLC_cap_width/100.0)/2.0) ); + hlf_barwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)GDC_bar_width/100.0)/2.0) ); /* used only for bars */ + hlf_hlccapwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)GDC_HLC_cap_width/100.0)/2.0) ); } /* scaled, sized, ready */ @@ -963,6 +965,7 @@ #if HAVE_LIBGD204 BGColor = GDC_BGColor; gdImageFilledRectangle(im,0,0, IMGWIDTH-1,IMGHEIGHT-1, BGColor); + gdImageAntialias(im, 1); #else BGColor = gdImageColorAllocate( im, l2gdcal(GDC_BGColor) ); #endif @@ -1317,7 +1320,6 @@ } setno = 0; } - if( ( GDC_grid || GDC_0Shelf ) && /* line color grid at 0 */ ( (lowest < 0.0 && highest > 0.0) || ( (lowest == 0.0 || highest == 0.0) && !(GDC_border&GDC_BORDER_X) ) ) ) @@ -1333,7 +1335,6 @@ gdImageLine( im, x2, y2, PX(num_points-1+(do_bar?2:0)), y2, LineColor ); setno = 0; /* set back to foremost */ } - /* x ticks and xlables */ if( GDC_grid || GDC_xaxis ) { @@ -1415,9 +1416,9 @@ &GDC_fontc[GDC_xaxisfont_size], gdc_xaxis_font, gdc_xaxis_ptsize, gdc_xaxis_rad, - PX(i)-1 - (int)((double)lftsz.w*cos_xangle + PX(i)-1 - (int)(FUZZ + (double)lftsz.w*cos_xangle + (double)lftsz.h*gdc_xaxis_rad/(M_PI/2.0)/2.0), - PY(lowest) + 2 + 1 + (int)((double)lftsz.w*sin_xangle), + PY(lowest) + 2 + 1 + (int)(FUZZ + (double)lftsz.w*sin_xangle), xlbl[xi], labelcolor, GDC_JUSTIFY_RIGHT, @@ -1609,7 +1610,7 @@ case GDC_STACK_BESIDE: { /* h/.5, h/1, h/1.5, h/2, ... */ - int new_barwdth = (int)( (float)hlf_barwdth / ((float)num_sets/2.0) ); + int new_barwdth = (int)( FUZZ+ (float)hlf_barwdth / ((float)num_sets/2.0) ); for( i=0; i<num_points; ++i ) for( j=0; j<num_sets; ++j ) if( uvals[j][i] != GDC_NOVALUE ) @@ -1645,7 +1646,7 @@ case GDC_STACK_BESIDE: { /* h/.5, h/1, h/1.5, h/2, ... */ - int new_barwdth = (int)( (float)hlf_barwdth / ((float)num_groups/2.0) ); + int new_barwdth = (int)( FUZZ + (float)hlf_barwdth / ((float)num_groups/2.0) ); for( i=0; i<num_points; ++i ) for( j=0; j<num_groups; ++j ) if( uvals[0+j*2][i] != GDC_NOVALUE && @@ -2013,7 +2014,7 @@ for( i=0; i<GDC_num_scatter_pts; ++i ) { - int hlf_scatterwdth = (int)( (float)(PX(2)-PX(1)) + int hlf_scatterwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)((GDC_scatter+i)->width)/100.0)/2.0) ); int scat_x = PX( (GDC_scatter+i)->point + (do_bar?1:0) ), scat_y = PY( (GDC_scatter+i)->val ); @@ -2129,11 +2130,10 @@ { if( GDC_border == GDC_BORDER_ALL || (GDC_border & GDC_BORDER_X) ) gdImageLine( im, PX(0), PY(lowest), PX(num_points-1+(do_bar?2:0)), PY(lowest), LineColor ); - if( GDC_border == GDC_BORDER_ALL || (GDC_border & GDC_BORDER_TOP) ) { setno = set_depth; - gdImageLine( im, PX(0), PY(highest), PX(num_points-1+(do_bar?2:0)), PY(highest), LineColor ); + gdImageLine( im, PX(0), PY(highest), PX(num_points-1+(do_bar?2:0)), PY(highest), LineColor ); setno = 0; } }
Index: pecl/gdchart/gdchart-src/gdc.h diff -u pecl/gdchart/gdchart-src/gdc.h:1.2 pecl/gdchart/gdchart-src/gdc.h:1.3 --- pecl/gdchart/gdchart-src/gdc.h:1.2 Wed Aug 27 05:51:56 2003 +++ pecl/gdchart/gdchart-src/gdc.h Fri Aug 29 18:56:50 2003 @@ -20,6 +20,7 @@ #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #endif +#define FUZZ 0.0001 #include <limits.h> #include <float.h> Index: pecl/gdchart/gdchart-src/gdc_pie.c diff -u pecl/gdchart/gdchart-src/gdc_pie.c:1.2 pecl/gdchart/gdchart-src/gdc_pie.c:1.3 --- pecl/gdchart/gdchart-src/gdc_pie.c:1.2 Wed Aug 27 05:51:56 2003 +++ pecl/gdchart/gdchart-src/gdc_pie.c Fri Aug 29 18:56:50 2003 @@ -386,6 +386,7 @@ #if HAVE_LIBGD204 im = gdImageCreateTrueColor( IMGWIDTH, IMGHEIGHT ); gdImageFilledRectangle(im,0,0, IMGWIDTH-1,IMGHEIGHT-1, GDCPIE_BGColor); + gdImageAntialias(im, 1); #else im = gdImageCreate( IMGWIDTH, IMGHEIGHT ); #endif @@ -440,15 +441,23 @@ { int edge_color = GDCPIE_EdgeColor == GDC_NOCOLOR? SliceColorShd[i]: EdgeColorShd; - +#if 0 gdImageLine( im, CX(i,1), CY(i,1), IX(i,1,1), IY(i,1,1), edge_color ); gdImageLine( im, CX(i,1), CY(i,1), IX(i,2,1), IY(i,2,1), edge_color ); - gdImageArc( im, CX(i,1), CY(i,1), +#endif + gdImageFilledArc( im, CX(i,1), CY(i,1), + (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), + TO_INT_DEG_FLOOR(slice_angle[1][i])+270, + TO_INT_DEG_FLOOR(slice_angle[2][i])+270, + SliceColorShd[i], gdPie ); + if(edge_color!=GDC_NOCOLOR) { + gdImageSetAntiAliased(im, edge_color); + gdImageFilledArc( im, CX(i,1), CY(i,1), (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), TO_INT_DEG_FLOOR(slice_angle[1][i])+270, - TO_INT_DEG_CEIL(slice_angle[2][i])+270, - edge_color ); - + TO_INT_DEG_FLOOR(slice_angle[2][i])+270, + gdAntiAliased, gdNoFill|gdEdged ); + } /* gdImageFilledArc( im, CX(i,1), CY(i,1), */ /* rad*ellipsex*2, rad*ellipsey*2, */ /* TO_INT_DEG_FLOOR(slice_angle[1][i])+270, */ @@ -456,11 +465,13 @@ /* SliceColorShd[i], */ /* gdPie ); */ /* attempt to fill, if slice is wide enough */ +#if 0 if( (ABS(IX(i,1,1)-IX(i,2,1)) + ABS(IY(i,1,1)-IY(i,2,1))) > 2 ) { float rad = rad1; /* local override */ gdImageFillToBorder( im, IX(i,0,1), IY(i,0,1), edge_color, SliceColorShd[i] ); } +#endif } } /* fill in connection to foreground pie */ @@ -479,14 +490,14 @@ tmp_slice[num_slice_angles].hidden = TRUE; tmp_slice[num_slice_angles].i = i; tmp_slice[num_slice_angles].slice = slice_angle[0][i]; - tmp_slice[num_slice_angles++].angle = slice_angle[1][i]; + tmp_slice[num_slice_angles++].angle = slice_angle[1][i]-0.01; if( RAD_DIST1(slice_angle[2][i]) < RAD_DIST2(slice_angle[0][i]) ) tmp_slice[num_slice_angles].hidden = FALSE; else tmp_slice[num_slice_angles].hidden = TRUE; tmp_slice[num_slice_angles].i = i; tmp_slice[num_slice_angles].slice = slice_angle[0][i]; - tmp_slice[num_slice_angles++].angle = slice_angle[2][i]; + tmp_slice[num_slice_angles++].angle = slice_angle[2][i]-0.01; /* identify which 2 slices (i) have a tangent parallel to depth angle */ if( slice_angle[1][i]<MOD_2PI(pie_3D_rad+M_PI_2) && slice_angle[2][i]>MOD_2PI(pie_3D_rad+M_PI_2) ) { @@ -521,18 +532,17 @@ else { rad -= 2.0; /* no peeking */ - gdp[0].x = OX(i,slice_angle[0][i],0); gdp[0].y = OY(i,slice_angle[0][i],0); - gdp[1].x = OX(i,slice_angle[0][i],1); gdp[1].y = OY(i,slice_angle[0][i],1); + gdp[0].x = OX(i,slice_angle[0][i]-0.011,0); gdp[0].y = OY(i,slice_angle[0][i]-0.011,0); + gdp[1].x = OX(i,slice_angle[0][i]-0.011,1); gdp[1].y = OY(i,slice_angle[0][i]-0.011,1); rad += 2.0; - gdp[2].x = OX(i,slice_angle[1][i],1); gdp[2].y = OY(i,slice_angle[1][i],1); - gdp[3].x = OX(i,slice_angle[1][i],0); gdp[3].y = OY(i,slice_angle[1][i],0); - gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i] ); - gdp[2].x = OX(i,slice_angle[2][i],1); gdp[2].y = OY(i,slice_angle[2][i],1); - gdp[3].x = OX(i,slice_angle[2][i],0); gdp[3].y = OY(i,slice_angle[2][i],0); + gdp[2].x = OX(i,slice_angle[1][i]-0.011,1); gdp[2].y = OY(i,slice_angle[1][i]-0.011,1); + gdp[3].x = OX(i,slice_angle[1][i]-0.011,0); gdp[3].y = OY(i,slice_angle[1][i]-0.011,0); + gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i]); + gdp[2].x = OX(i,slice_angle[2][i]-0.011,1); gdp[2].y = OY(i,slice_angle[2][i]-0.011,1); + gdp[3].x = OX(i,slice_angle[2][i]-0.011,0); gdp[3].y = OY(i,slice_angle[2][i]-0.011,0); gdImageFilledPolygon( im, gdp, 4, SliceColorShd[i] ); } - if( GDCPIE_EdgeColor != GDC_NOCOLOR ) { gdImageLine( im, CX(i,0), CY(i,0), CX(i,1), CY(i,1), EdgeColorShd ); @@ -558,13 +568,23 @@ EdgeColorShd; /* last += val[i]; */ /* EXPLODE_CX_CY( slice_angle[0][i], i ); */ +#if 0 gdImageLine( im, CX(i,0), CY(i,0), IX(i,1,0), IY(i,1,0), edge_color ); gdImageLine( im, CX(i,0), CY(i,0), IX(i,2,0), IY(i,2,0), edge_color ); - gdImageArc( im, CX(i,0), CY(i,0), +#endif + gdImageFilledArc( im, CX(i,0), CY(i,0), + (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), + (TO_INT_DEG_FLOOR(slice_angle[1][i])+270)%360, + (TO_INT_DEG_FLOOR(slice_angle[2][i])+270)%360, + SliceColor[i], gdPie ); + if(edge_color!=GDC_NOCOLOR) { + gdImageSetAntiAliased(im, edge_color); + gdImageFilledArc( im, CX(i,0), CY(i,0), (int)(rad*ellipsex*2.0), (int)(rad*ellipsey*2.0), (TO_INT_DEG_FLOOR(slice_angle[1][i])+270)%360, - (TO_INT_DEG_CEIL(slice_angle[2][i])+270)%360, - edge_color ); + (TO_INT_DEG_FLOOR(slice_angle[2][i])+270)%360, + gdAntiAliased, gdNoFill|gdEdged ); + } /* antialiasing here */ /* likely only on the face? */ /* bugs in gd2.0.0 */ @@ -579,6 +599,7 @@ /* SliceColor[i], */ /* gdPie ); */ /* attempt to fill, if slice is wide enough */ +#if 0 { float rad = rad1; /* local override */ if( (ABS(IX(i,1,1)-IX(i,2,1)) + ABS(IY(i,1,1)-IY(i,2,1))) > 2 ) @@ -588,6 +609,7 @@ /* catch missed pixels on narrow slices */ gdImageLine( im, CX(i,0), CY(i,0), IX(i,0,0), IY(i,0,0), SliceColor[i] ); } +#endif } } Index: pecl/gdchart/gdchart-src/gdchart.c diff -u pecl/gdchart/gdchart-src/gdchart.c:1.4 pecl/gdchart/gdchart-src/gdchart.c:1.5 --- pecl/gdchart/gdchart-src/gdchart.c:1.4 Wed Aug 27 18:49:11 2003 +++ pecl/gdchart/gdchart-src/gdchart.c Fri Aug 29 18:56:50 2003 @@ -18,14 +18,16 @@ #include "gdchart.h" #include "ext/standard/php_image.h" +#define gdImageLine gdImageAALine + #define HIGHSET 0 #define LOWSET 1 #define CLOSESET 2 /* scaled translation onto graph */ -#define PX( x ) (int)( xorig + (setno*xdepth_3D) + (x)*xscl ) -#define PY( y ) (int)( yorig - (setno*ydepth_3D) + (y)*yscl ) -#define PV( y ) (int)( vyorig - (setno*ydepth_3D) + (y)*vyscl ) +#define PX( x ) (int)( xorig + (setno*xdepth_3D) + (x)*xscl + FUZZ ) +#define PY( y ) (int)( yorig - (setno*ydepth_3D) + (y)*yscl + FUZZ ) +#define PV( y ) (int)( vyorig - (setno*ydepth_3D) + (y)*vyscl + FUZZ ) #define SET_RECT( gdp, x1, x2, y1, y2 ) gdp[0].x = gdp[3].x = x1, \ gdp[0].y = gdp[1].y = y1, \ @@ -61,7 +63,7 @@ int clr[], int clrshd[] ) { -#define F(x,i) (int)( (float)((x)-x1)*slope[i]+(float)y1[i] ) +#define F(x,i) (int)( FUZZ + (float)((x)-x1)*slope[i]+(float)y1[i] ) float depth_slope = xdepth==0? FLT_MAX: (float)ydepth/(float)xdepth; CREATE_ARRAY1( slope, float, num_sets ); /* float slope[num_sets] */ CREATE_ARRAY1( lnclr, int, num_sets ); /* int slope[num_sets] */ @@ -134,7 +136,7 @@ y_intercept = (y1 > y0 && y2 < y0) || /* line crosses y0 */ (y1 < y0 && y2 > y0)? - (int)((1.0/ABS(line_slope))*(float)(ABS(y1-y0)))+x1: + (int)(FUZZ + (1.0/ABS(line_slope))*(float)(ABS(y1-y0)))+x1: 0; /* never */ /* edging along y0 depth */ @@ -708,8 +710,8 @@ #define HYP_DEPTH ( (double)((IMGWIDTH+IMGHEIGHT)/2) * ((double)GDC_3d_depth)/100.0 ) #define RAD_DEPTH ( (double)GDC_3d_angle*2*M_PI/360 ) - xdepth_3D = threeD? (int)( cos(RAD_DEPTH) * HYP_DEPTH ): 0; - ydepth_3D = threeD? (int)( sin(RAD_DEPTH) * HYP_DEPTH ): 0; + xdepth_3D = threeD? (int)( FUZZ + cos(RAD_DEPTH) * HYP_DEPTH ): 0; + ydepth_3D = threeD? (int)( FUZZ + sin(RAD_DEPTH) * HYP_DEPTH ): 0; xdepth_3Dtotal = xdepth_3D*set_depth; ydepth_3Dtotal = ydepth_3D*set_depth; annote_hgt = GDC_annotation && *(GDC_annotation->note)? @@ -770,8 +772,8 @@ } else /* length & width due to the angle */ { - len = (int)( (double)lftsz.w * sin_xangle + (double)lftsz.h * cos_xangle ); - wdth = (int)( (double)lftsz.h / sin_xangle ); + len = (int)( FUZZ + (double)lftsz.w * sin_xangle + (double)lftsz.h * cos_xangle ); + wdth = (int)( FUZZ + (double)lftsz.h / sin_xangle ); } } biggest = MAX( len, biggest ); /* last seg */ @@ -851,7 +853,7 @@ /* lowest = (lowest-ypoints[0]) - */ /* ( ( ((lowest-ypoints[0])/ylbl_interval)*ylbl_interval ) - */ /* ( (float)((int)((lowest-ypoints[0])/ylbl_interval))*ylbl_interval ) ); */ - lowest = ylbl_interval * (float)(int)((lowest-ypoints[0])/ylbl_interval); + lowest = ylbl_interval * (float)(int)(FUZZ + (lowest-ypoints[0])/ylbl_interval); } /* find smallest interval-point > highest */ tmp_highest = lowest; @@ -942,8 +944,8 @@ /*???? yorig = GDC_hard_yorig; FRED - check email */ GDC_hard_yorig = yorig; - hlf_barwdth = (int)( (float)(PX(2)-PX(1)) * (((float)GDC_bar_width/100.0)/2.0) ); /* used only for bars */ - hlf_hlccapwdth = (int)( (float)(PX(2)-PX(1)) * (((float)GDC_HLC_cap_width/100.0)/2.0) ); + hlf_barwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)GDC_bar_width/100.0)/2.0) ); /* used only for bars */ + hlf_hlccapwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)GDC_HLC_cap_width/100.0)/2.0) ); } /* scaled, sized, ready */ @@ -963,6 +965,7 @@ #if HAVE_LIBGD204 BGColor = GDC_BGColor; gdImageFilledRectangle(im,0,0, IMGWIDTH-1,IMGHEIGHT-1, BGColor); + gdImageAntialias(im, 1); #else BGColor = gdImageColorAllocate( im, l2gdcal(GDC_BGColor) ); #endif @@ -1317,7 +1320,6 @@ } setno = 0; } - if( ( GDC_grid || GDC_0Shelf ) && /* line color grid at 0 */ ( (lowest < 0.0 && highest > 0.0) || ( (lowest == 0.0 || highest == 0.0) && !(GDC_border&GDC_BORDER_X) ) ) ) @@ -1333,7 +1335,6 @@ gdImageLine( im, x2, y2, PX(num_points-1+(do_bar?2:0)), y2, LineColor ); setno = 0; /* set back to foremost */ } - /* x ticks and xlables */ if( GDC_grid || GDC_xaxis ) { @@ -1415,9 +1416,9 @@ &GDC_fontc[GDC_xaxisfont_size], gdc_xaxis_font, gdc_xaxis_ptsize, gdc_xaxis_rad, - PX(i)-1 - (int)((double)lftsz.w*cos_xangle + PX(i)-1 - (int)(FUZZ + (double)lftsz.w*cos_xangle + (double)lftsz.h*gdc_xaxis_rad/(M_PI/2.0)/2.0), - PY(lowest) + 2 + 1 + (int)((double)lftsz.w*sin_xangle), + PY(lowest) + 2 + 1 + (int)(FUZZ + (double)lftsz.w*sin_xangle), xlbl[xi], labelcolor, GDC_JUSTIFY_RIGHT, @@ -1609,7 +1610,7 @@ case GDC_STACK_BESIDE: { /* h/.5, h/1, h/1.5, h/2, ... */ - int new_barwdth = (int)( (float)hlf_barwdth / ((float)num_sets/2.0) ); + int new_barwdth = (int)( FUZZ+ (float)hlf_barwdth / ((float)num_sets/2.0) ); for( i=0; i<num_points; ++i ) for( j=0; j<num_sets; ++j ) if( uvals[j][i] != GDC_NOVALUE ) @@ -1645,7 +1646,7 @@ case GDC_STACK_BESIDE: { /* h/.5, h/1, h/1.5, h/2, ... */ - int new_barwdth = (int)( (float)hlf_barwdth / ((float)num_groups/2.0) ); + int new_barwdth = (int)( FUZZ + (float)hlf_barwdth / ((float)num_groups/2.0) ); for( i=0; i<num_points; ++i ) for( j=0; j<num_groups; ++j ) if( uvals[0+j*2][i] != GDC_NOVALUE && @@ -2013,7 +2014,7 @@ for( i=0; i<GDC_num_scatter_pts; ++i ) { - int hlf_scatterwdth = (int)( (float)(PX(2)-PX(1)) + int hlf_scatterwdth = (int)( FUZZ + (float)(PX(2)-PX(1)) * (((float)((GDC_scatter+i)->width)/100.0)/2.0) ); int scat_x = PX( (GDC_scatter+i)->point + (do_bar?1:0) ), scat_y = PY( (GDC_scatter+i)->val ); @@ -2129,11 +2130,10 @@ { if( GDC_border == GDC_BORDER_ALL || (GDC_border & GDC_BORDER_X) ) gdImageLine( im, PX(0), PY(lowest), PX(num_points-1+(do_bar?2:0)), PY(lowest), LineColor ); - if( GDC_border == GDC_BORDER_ALL || (GDC_border & GDC_BORDER_TOP) ) { setno = set_depth; - gdImageLine( im, PX(0), PY(highest), PX(num_points-1+(do_bar?2:0)), PY(highest), LineColor ); + gdImageLine( im, PX(0), PY(highest), PX(num_points-1+(do_bar?2:0)), PY(highest), LineColor ); setno = 0; } }