line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Line; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Line::VERSION = '1.0113'; |
3
|
8
|
|
|
8
|
|
1224
|
use Moo; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
50
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'SVG::Estimate::Shape'; |
6
|
|
|
|
|
|
|
with 'SVG::Estimate::Role::Pythagorean'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
SVG::Estimate::Line - Handles estimating straight lines. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 1.0113 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $line = SVG::Estimate::Line->new( |
19
|
|
|
|
|
|
|
transformer => $transform, |
20
|
|
|
|
|
|
|
start_point => [45,13], |
21
|
|
|
|
|
|
|
x1 => 1, |
22
|
|
|
|
|
|
|
y1 => 3, |
23
|
|
|
|
|
|
|
x2 => 4.6, |
24
|
|
|
|
|
|
|
y2 => 3, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $length = $line->length; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 INHERITANCE |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This class extends L and consumes L. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new() |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Constructor. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item x1 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Float representing the x start point. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item y1 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Float representing the y start point. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item x2 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Float representing the x end point. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item y2 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Float representing the y end point. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has x1 => ( |
62
|
|
|
|
|
|
|
is => 'ro', |
63
|
|
|
|
|
|
|
default => sub { 0 }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has y1 => ( |
67
|
|
|
|
|
|
|
is => 'ro', |
68
|
|
|
|
|
|
|
default => sub { 0 }, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has x2 => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
default => sub { 0 }, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has y2 => ( |
77
|
|
|
|
|
|
|
is => 'ro', |
78
|
|
|
|
|
|
|
default => sub { 0 }, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub BUILDARGS { |
82
|
138
|
|
|
138
|
0
|
10279
|
my ($class, @args) = @_; |
83
|
|
|
|
|
|
|
##Upgrade to hashref |
84
|
138
|
50
|
|
|
|
601
|
my $args = @args % 2 ? $args[0] : { @args }; |
85
|
138
|
|
|
|
|
232
|
foreach my $arg (qw(x1 x2 y1 y2)) { |
86
|
552
|
|
50
|
|
|
721
|
$args->{$arg} //= 0; |
87
|
|
|
|
|
|
|
} |
88
|
138
|
50
|
|
|
|
176
|
return $args unless exists $args->{transformer}; |
89
|
138
|
|
|
|
|
435
|
my $point1 = $args->{transformer}->transform([$args->{x1}, $args->{y1}]); |
90
|
138
|
|
|
|
|
1259
|
my $point2 = $args->{transformer}->transform([$args->{x2}, $args->{y2}]); |
91
|
138
|
|
|
|
|
839
|
$args->{x1} = $point1->[0]; |
92
|
138
|
|
|
|
|
143
|
$args->{y1} = $point1->[1]; |
93
|
138
|
|
|
|
|
141
|
$args->{x2} = $point2->[0]; |
94
|
138
|
|
|
|
|
139
|
$args->{y2} = $point2->[1]; |
95
|
138
|
|
|
|
|
142
|
$args->{draw_start} = $point1; |
96
|
138
|
|
|
|
|
138
|
$args->{draw_end} = $point2; |
97
|
138
|
100
|
|
|
|
402
|
$args->{min_y} = $args->{y1} < $args->{y2} ? $args->{y1} : $args->{y2}; |
98
|
138
|
100
|
|
|
|
224
|
$args->{max_y} = $args->{y1} > $args->{y2} ? $args->{y1} : $args->{y2}; |
99
|
138
|
100
|
|
|
|
344
|
$args->{min_x} = $args->{x1} < $args->{x2} ? $args->{x1} : $args->{x2}; |
100
|
138
|
100
|
|
|
|
318
|
$args->{max_x} = $args->{x1} > $args->{x2} ? $args->{x1} : $args->{x2}; |
101
|
138
|
|
|
|
|
308
|
$args->{shape_length} = $class->pythagorean($point1, $point2); |
102
|
138
|
|
|
|
|
2196
|
return $args; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |