| 1 | package SVG::Estimate::Polygon; | ||
| 2 | $SVG::Estimate::Polygon::VERSION = '1.0111'; | ||
| 3 | use Moo; | ||
| 4 | use Math::Trig qw/pi/; | ||
| 5 | use Clone qw/clone/; | ||
| 6 | |||
| 7 | extends 'SVG::Estimate::Polyline'; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | SVG::Estimate::Polygon - Handles estimating shapes of more than 3 points with straight lines between the points. | ||
| 12 | |||
| 13 | =head1 VERSION | ||
| 14 | |||
| 15 | version 1.0111 | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | my $polygon = SVG::Estimate::Polygon->new( | ||
| 20 | transformer => $transform, | ||
| 21 | start_point => [45,13], | ||
| 22 | points => '20,20 40,25 60,40 80,120 120,140 200,180', | ||
| 23 | ); | ||
| 24 | |||
| 25 | my $length = $polygon->length; | ||
| 26 | |||
| 27 | =head1 INHERITANCE | ||
| 28 | |||
| 29 | This class extends L<SVG::Estimate::Polyline>. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | ##Take the first pair, and make it the last to close the shape. | ||
| 34 | around _get_pairs => sub { | ||
| 35 | my $orig = shift; | ||
| 36 | my $self = shift; | ||
| 37 | my @points = $self->$orig(@_); | ||
| 38 | push @points, $points[0]; | ||
| 39 | return @points | ||
| 40 | }; | ||
| 41 | |||
| 42 | 1; |