ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

Problem with arc (bogen) #65

Open sciurius opened 1 year ago

sciurius commented 1 year ago

The attached program produces the following image arc-wrong while it should look like arc-good

Even though the bogen function is considered obsolete, it is still the only method available to produce arcs in the style of SVG.

arcs.zip

ssimms commented 11 months ago

Your code has:

$xo->bogen( 0, -50, 100, -50, 1, 0, 0, 1 );

... where the arguments are x1, y1, x2, y2, radius, etc., and where the comment for the function has the warning: "$radius * 2 cannot be smaller than the distance from [x1,y1] to [x2,y2].

If I'm reading things correctly, the code is failing because the radius of the circle is set to 1, when it should be set to 50. If I change the radius to 50, I get the expected output. Am I misreading something? (I usually am when I think there's a problem with one of your test cases, so I'm very willing to believe that's happening here.)

sciurius commented 11 months ago

Sorry if I was not clear.

Since it is impossible to draw an arc when the radius is too small I think bogen should throw an error, or silently extend the radius.

The test program mimics the result from my SVG to PDF renderer. The test file came from from an SVG site. Maybe the intention was to test the 'feature' that according to the SVG specs the radius should be extended to half the distance from [x1,y1] to [x2,y2].