Graphics-Fig
view release on metacpan or search on metacpan
lib/Graphics/Fig/Arc.pm view on Meta::CPAN
# Find the center and radius.
#
my $half_cot = cot($angle / 2) / 2;
my $xc = $x1 + ($x3 - $x1) / 2 + ($y3 - $y1) * $half_cot;
my $yc = $y1 + ($y3 - $y1) / 2 - ($x3 - $x1) * $half_cot;
my $dx = $x1 - $xc;
my $dy = $y1 - $yc;
my $r = sqrt($dx * $dx + $dy * $dy);
#
# First, find the bounding box of the endpoints. Then for each
# axis the arc crosses, expand the box as needed.
#
my $bbox = Graphics::Fig::Parameters::getbboxFromPoints($point1, $point3);
if (&crosses_axis($point1, $point3, [ $xc - $r, $yc ]) * $angle > 0) {
if ($xc - $r < ${$bbox}[0][0]) {
${$bbox}[0][0] = $xc - $r;
}
}
if (&crosses_axis($point1, $point3, [ $xc, $yc - $r ]) * $angle > 0) {
if ($yc - $r < ${$bbox}[0][1]) {
t/advanced.t view on Meta::CPAN
my $fig = Graphics::Fig->new({
color => "green",
arrowStyle => "filled-indented",
arrowWidth => "1.5 mm",
arrowHeight => "2.0 mm",
units => "cm"
});
#
# Draw arrows from a given center to the corners of a pentagon.
# Save the endpoints.
#
my $N = 5;
my $R = 2;
my $center = [ 4, 4 ];
my @polygon;
for (my $i = 0; $i < $N; ++$i) {
$fig->lineto($R, 360.0 * -$i/$N, { position => $center,
arrowMode => "forw",
color => "#BEBEBE" });
push(@polygon, $fig->getposition());
( run in 1.166 second using v1.01-cache-2.11-cpan-beeb90c9504 )