Imager-Graph
view release on metacpan or search on metacpan
lib/Imager/Graph/Pie.pm view on Meta::CPAN
my %entry = ( 'y'=>$y );
$entry{line} = [ line_from_points($tcx, $y, $tcx+1, $y) ];
$entry{left} = -$radius;
$entry{right} = $radius;
for my $angle ($begin, $end) {
my $ex = $cx + cos($angle)*$radius;
my $ey = $cy + sin($angle)*$radius;
my @line = line_from_points($cx, $cy, $ex, $ey);
#_test_line($cx, $cy, @line);
#_test_line($ex, $ey, @line);
my $goodsign = $line[0] * $tcx + $line[1] * $tcy + $line[2];
for my $pos (@entry{qw/left right/}) {
my $sign = $line[0] * ($pos+$tcx) + $line[1] * $y + $line[2];
if ($goodsign * $sign < 0) {
if (my @p = intersect_lines(@line, @{$entry{line}})) {
# die "$goodsign $sign ($pos, $tcx) no intersect (@line) (@{$entry{line}})" ; # this would be wierd
#_test_line(@p, @line);
#_test_line(@p, @{$entry{line}});
$pos = $p[0]-$tcx;
}
else {
return;
}
}
( run in 2.129 seconds using v1.01-cache-2.11-cpan-71847e10f99 )