[fpc-pascal] Agg Pas Arcs

James Richters james at productionautomation.net
Wed Aug 30 16:54:44 CEST 2017


I'm having an issue with drawing Arcs with AggPas, and I can't quite put my finger on it...   What's happening is that small arc segments are just not being drawn... they are not super tiny segments, they should end up being at least 100 pixels long, but they have a pretty big radius, but the radius itself is not the issue because I can draw larger arc segments with even larger radii and they have no issues.  It seems to be some combination of parameters.  Basically I am scaling my drawing with a multiplier and when I cross a certain point, these arcs disappear from the drawing.    But I notice this only happens with the Arc() function, not ArcTo() but I'm using both at the same time.. I'm using MoveTo(), LineTo, and ArcTo() to draw a highlighted path, and at the same time Line() and Arc() to draw a centerline so what happens is that as I zoom out, decreasing the scale,  the highlighted path is there, but the centerline disappears for these arc segments.  I've reduced this down to trying to just draw the arc in question and I still have the same issue, so I know it doesn't have anything to do with any other functions.

It would not be easy to just use ArcTo() for the centerline as well, because it would  break the path I am building, and if I try to draw the path so far, then use ArcTo for the centerline, then start another path, I end up with a quite noticeable overlap in my highlighting where the overlap is highlighted twice... so it would be nice if I could figure out what's going on with ArcTo() 

Here is some test data for one of the arcs that just will not draw with AggPas:
Here is how I am implementing the arc command:

agg^.arc(Drawinfo.gi*pixelscale+Draw_X_offset,Drawinfo.gj*pixelscale+Draw_Y_offset,Drawinfo.r*pixelscale,Drawinfo.r*pixelscale,Drawinfo.ea,Drawinfo.sa);
If Pixelscale drops below a certain point, the arc will not draw.   I ran several tests, then tried it with just hard coded values as follows:

agg^.arc(-600470.258096880350,168254.083748858280,624074.001867781300,624074.001867781300,6.011216001395,6.010880670454);    //Draws Arc
agg^.arc(-540359.532287192330,151479.575373972450,561666.601681003190,561666.601681003190,6.011216001395,6.010880670454);    //Draws Arc
agg^.arc(-486259.879058473110,136382.517836575210,505499.941512902880,505499.941512902880,6.011216001395,6.010880670454);    //Does Not Draw Arc
Any Pixel scales smaller than this result in no arc being drawn.

Now I can draw the same arc with the following code:

total_arc_angle:=Drawinfo.ea-Drawinfo.sa;
If Total_Arc_angle<0 then
   Total_Arc_Angle:=Total_Arc_Angle+(2*Pi);
agg^.resetpath;
agg^.moveto(Drawinfo.px*pixelscale+Draw_X_offset,Drawinfo.py*pixelscale+Draw_Y_offset);
If Total_arc_angle > Pi then
    agg^.arcto(Drawinfo.r*pixelscale,Drawinfo.r*pixelscale,Total_Arc_Angle,True,True,Drawinfo.gx*pixelscale+Draw_X_offset,Drawinfo.gy*pixelscale+Draw_Y_offset)
Else
    agg^.arcto(Drawinfo.r*pixelscale,Drawinfo.r*pixelscale,Total_Arc_Angle,False,True,Drawinfo.gx*pixelscale+Draw_X_offset,Drawinfo.gy*pixelscale+Draw_Y_offset);
agg^.drawPath(StrokeOnly); 

With this I also performed the same 3 tests as above with the following:
agg^.moveto(609.165546484752,409.256438718313);
agg^.arcto(624074.001867781300,624074.001867781300,0.000335330941,False,True,665.125058651162,609.784932227478);   // Draws Arc

agg^.moveto(611.948991836276,419.230794846482);
agg^.arcto(561666.601681003190,561666.601681003190,0.000335330941,False,True,662.312552786046,599.706439004730);   //Draws Arc

agg^.moveto(614.454092652649,428.207715361834);
agg^.arcto(505499.941512902880,505499.941512902880,0.000335330941,False,True,659.781297507441,590.635795104257);   //Draws Arc

With MoveTo and ArcTo, I can draw the arc any size, even reducing the pixel scale down so far that the entire drawing is 1 pixel

Does anyone know what's going on with this?   It seems like the kind of thing where some internal calculation does not have enough precision, or something is overflowing..  but it's strange that ArcTo always works to draw the same exact arc.

James




More information about the fpc-pascal mailing list