File Coverage

lib/SVG/Estimate/Role/MakePolygon.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1             package SVG::Estimate::Role::MakePolygon;
2             $SVG::Estimate::Role::MakePolygon::VERSION = '1.0114';
3 12     12   6203 use strict;
  12         27  
  12         417  
4 12     12   65 use Moo::Role;
  12         29  
  12         84  
5 12     12   7574 use Image::SVG::Transform;
  12         133822  
  12         482  
6 12     12   4709 use SVG::Estimate::Polygon;
  12         29  
  12         2145  
7              
8             =head1 NAME
9              
10             SVG::Estimate::Role::MakePolygon - Approximate shapes that are hard to estimate
11              
12             =head1 VERSION
13              
14             version 1.0114
15              
16             =head1 METHODS
17              
18             =head2 make_polygon ( $args )
19              
20             Class method.
21              
22             Make an SVG::Estimate::Polygon out of a set of point approximating the consumer's shape.
23              
24             Requires that the consumer provide a C method.
25              
26             =cut
27              
28             sub make_polygon {
29 9     9 1 22 my ($class, $args) = @_;
30 9         14 my @points;
31 9         37 for (my $t = 0.0; $t <= 1.0; $t += 1/12) {
32 117         302 my $point = $class->this_point($args, $t);
33 117         266 $point = $args->{transformer}->transform($point);
34 117         20733 push @points, $point;
35             }
36 9         25 my $polygon_points = join ' ', map { join ',', @{ $_ } } @points;
  117         144  
  117         537  
37             ##Have to send in an empty transform object
38 9         196 my $littleT = Image::SVG::Transform->new();
39 9         264 return SVG::Estimate::Polygon->new(points => $polygon_points, transformer => $littleT, start_point => $args->{start_point}, );
40             }
41              
42              
43             1;