This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics
Id:
18222
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
ntyni [...] iki.fi
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
0.51
Fixed in:
(no value)



Subject: PDF::API2::Content::bogen() broken
Hi, the PDF::API2::Content::bogen() function is broken for cases where ($y2-$y1) < 0. Consider the attached test script, which tries to draw four squares with differently rounded corners, corresponding to the four combinations of the 'span' and 'larc' parameters. All of these are wrong for the upper and lower right quadrants. I'm attaching a patch that fixes this. Most of the trouble is fixed by simplifying the 'alfa' angle handling. Furthermore, in the case of span=1 and larc=1, the loop that calls curve() may run out of data points, resulting in the last curve being drawn back to the center of the circle. The patch fixes this as well. I have investigated this on Debian GNU/Linux, Perl 5.8.8 and PDF::API2 0.51. The bug was originally reported by Wouter Van Hemel as Debian bug #356419, http://bugs.debian.org/356419 . Please consider including the patch in the next release. Cheers, -- Niko Tyni (on behalf of the Debian Perl Group) ntyni@iki.fi
Subject: pdf-test.pl
#!/usr/bin/perl -w use strict; use PDF::API2; my $p = PDF::API2->new; my $page = $p->page; my $rounded = $page->gfx; $rounded->strokecolor('black'); for my $i (0..3) { my $span = $i % 2; my $largearc = int($i / 2); my $xbase = 150 * ($i % 2) + 300; my $ybase = 150 * int($i / 2) + 300; $rounded->circle($xbase, $ybase, 2); # 70 650 $rounded->move($xbase-40,$ybase+20); $rounded->bogen($xbase-40, $ybase+20, $xbase-20, $ybase+40, 20, 0, $largearc, $span); $rounded->line ($xbase-20, $ybase+40, $xbase+20, $ybase+40); $rounded->bogen($xbase+20, $ybase+40, $xbase+40, $ybase+20, 20, 0, $largearc, $span); $rounded->line ($xbase+40, $ybase+20, $xbase+40, $ybase-20); $rounded->bogen($xbase+40, $ybase-20, $xbase+20, $ybase-40, 20, 0, $largearc, $span); $rounded->line ($xbase+20, $ybase-40, $xbase-20, $ybase-40); $rounded->bogen($xbase-20, $ybase-40, $xbase-40, $ybase-20, 20, 0, $largearc, $span); $rounded->line ($xbase-40, $ybase-20, $xbase-40, $ybase+20); $rounded->stroke; } $p->saveas('f.pdf');
Subject: pdf-api2.patch
--- /usr/share/perl5/PDF/API2/Content.pm 2006/03/17 19:18:08 1.1 +++ /usr/share/perl5/PDF/API2/Content.pm 2006/03/17 19:29:09 @@ -940,24 +940,17 @@ my ($self,$x1,$y1,$x2,$y2,$r,$move,$larc,$spf) = @_; my ($p0_x,$p0_y,$p1_x,$p1_y,$p2_x,$p2_y,$p3_x,$p3_y); my $x=$x2-$x1; - $x=$x1-$x2 if($spf>0); my $y=$y2-$y1; - $y=$y1-$y2 if($spf>0); my $z=sqrt($x**2+$y**2); my $alfa_rad=asin($y/$z); - if($spf>0) - { - $alfa_rad-=pi/2 if($x<0); - $alfa_rad=-$alfa_rad if($y>0); - } - else - { - $alfa_rad+=pi/2 if($x<0); - $alfa_rad=-$alfa_rad if($y<0); - } + $alfa_rad+=pi/2 if($x<0 and $y>0); + $alfa_rad-=pi/2 if($x<0 and $y<0); my $alfa=rad2deg($alfa_rad); + # use the complement angle for span + $alfa -= 180 if($spf>0); + my $d=2*$r; my ($beta,$beta_rad,@points); @@ -991,8 +984,14 @@ $p1_y= $y + shift @points; $p2_x= $x + shift @points; $p2_y= $y + shift @points; - $p3_x= $x + shift @points; - $p3_y= $y + shift @points; + # if we run out of data points, use the end point instead + if (scalar @points == 0) { + $p3_x = $x2; + $p3_y = $y2; + } else { + $p3_x= $x + shift @points; + $p3_y= $y + shift @points; + } $self->curve($p1_x,$p1_y,$p2_x,$p2_y,$p3_x,$p3_y); shift @points; shift @points;
appalied to CVS.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.