| 1 | package SVG::Estimate::Role::MakePolygon; | ||||||||||
| 2 | 6 | $SVG::Estimate::Role::MakePolygon::VERSION = '1.0111'; | |||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | ▶ | use Image::SVG::Transform; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 6 | ▶ | use SVG::Estimate::Polygon; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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.0111 | ||||||||||
| 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<this_point> method. | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | sub make_polygon { | ||||||||||
| 29 | 2 | ▶ | my ($class, $args) = @_; | ||||||||
|
Subroutine
make_polygon: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 2 | my @points; | |||||||||
| 31 | 2 | ▶ | for (my $t = 0.0; $t <= 1.0; $t += 1/12) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 26 | my $point = $class->this_point($args, $t); | |||||||||
| 33 | 26 | $point = $args->{transformer}->transform($point); | |||||||||
| 34 | 26 | push @points, $point; | |||||||||
| 35 | } | ||||||||||
| 36 | 2 | my $polygon_points = join ' ', map { join ',', @{ $_ } } @points; | |||||||||
| 37 | ##Have to send in an empty transform object | ||||||||||
| 38 | 2 | my $littleT = Image::SVG::Transform->new(); | |||||||||
| 39 | 2 | return SVG::Estimate::Polygon->new(points => $polygon_points, transformer => $littleT, start_point => $args->{start_point}, ); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 6 | 1; | |||||||||