Post without Account — your post will be reviewed, and if appropriate, posted under Anonymous. You can also use this link to report any problems registering or logging in.

RT 98538 - -arc() sweep angle problem

  • 1 Replies
  • 1128 Views
*

Offline Phil

  • Global Moderator
  • Sr. Member
  • *****
  • 437
    • View Profile
RT 98538 - -arc() sweep angle problem
« October 20, 2016, 07:23:55 PM »
Subject:    arc() sweep angle problem
Date:    Tue, 02 Sep 2014 10:59:52 -0400
To:    bug-PDF-API2 [...] rt.cpan.org
 
PDF::API2 v2.022   Perl 5.16.3  Windows 7   severity: Important

In Content.pm, the arc() method refuses to cross the 0 degree line. Instead of sweeping across the 0 degree line from a larger angle to a smaller one, it appears to always be sweeping from the smaller angle to the larger one, even if $alpha is given as the larger (starting) angle and $beta is the smaller (ending) angle.

I have submitted a POD change (documentation) to the maintainer to point out this limitation. It would probably be better to remove the limitation by splitting the arc draw into $alpha-to-360 and 0-to-$beta (if $alpha > $beta) sub-arcs.

Note that the pie() method (Content.pm) makes use of arc(), and so has this same limitation.
#
Subject:    [rt.cpan.org #98538]
Date:    Sat, 23 Jan 2016 13:10:03 -0500
To:    bug-PDF-API2 [...] rt.cpan.org
 
I don't think it will be as simple as always moving counter-clockwise, although that is a possible solution. Can anyone come up with a reason to permit a clockwise direction of travel from $alpha to $beta? If there isn't, forcing CCW direction can force the arc() routine to cross over the 0 degree line (the desired result here). Otherwise, if there may be a legitimate reason (such as a future embedding of text or directional annotations such as arrowheads in a line), an %opts flag could be added to override the default CCW direction.

Thoughts?

<formatting cleanup - Mod.>
« Last Edit: May 01, 2017, 11:10:00 AM by Phil »

*

Offline Phil

  • Global Moderator
  • Sr. Member
  • *****
  • 437
    • View Profile
Re: RT 98538 - -arc() sweep angle problem
« Reply #1: November 14, 2016, 08:36:00 PM »
Fixed in 3.001

  • arc() and pie(), as well as internal routine _arctocurve(), are given an optional direction flag (default CCW draw)
  • The curve is automatically split when it crosses the 0 degree angle.
  • For all elliptical/circular curve routines, clarify in the POD that the semidiameters are for the x and y axes, not major and minor axes!
  • Checks added for non-positive radii and zero-degree sweeps.