line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Line; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Line::VERSION = '1.0114'; |
3
|
8
|
|
|
8
|
|
1430
|
use Moo; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
71
|
|
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.0114 |
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
|
12626
|
my ($class, @args) = @_; |
83
|
|
|
|
|
|
|
##Upgrade to hashref |
84
|
138
|
50
|
|
|
|
785
|
my $args = @args % 2 ? $args[0] : { @args }; |
85
|
138
|
|
|
|
|
249
|
foreach my $arg (qw(x1 x2 y1 y2)) { |
86
|
552
|
|
50
|
|
|
986
|
$args->{$arg} //= 0; |
87
|
|
|
|
|
|
|
} |
88
|
138
|
50
|
|
|
|
237
|
return $args unless exists $args->{transformer}; |
89
|
138
|
|
|
|
|
895
|
my $point1 = $args->{transformer}->transform([$args->{x1}, $args->{y1}]); |
90
|
138
|
|
|
|
|
1587
|
my $point2 = $args->{transformer}->transform([$args->{x2}, $args->{y2}]); |
91
|
138
|
|
|
|
|
1045
|
$args->{x1} = $point1->[0]; |
92
|
138
|
|
|
|
|
181
|
$args->{y1} = $point1->[1]; |
93
|
138
|
|
|
|
|
155
|
$args->{x2} = $point2->[0]; |
94
|
138
|
|
|
|
|
149
|
$args->{y2} = $point2->[1]; |
95
|
138
|
|
|
|
|
226
|
$args->{draw_start} = $point1; |
96
|
138
|
|
|
|
|
170
|
$args->{draw_end} = $point2; |
97
|
138
|
100
|
|
|
|
525
|
$args->{min_y} = $args->{y1} < $args->{y2} ? $args->{y1} : $args->{y2}; |
98
|
138
|
100
|
|
|
|
275
|
$args->{max_y} = $args->{y1} > $args->{y2} ? $args->{y1} : $args->{y2}; |
99
|
138
|
100
|
|
|
|
409
|
$args->{min_x} = $args->{x1} < $args->{x2} ? $args->{x1} : $args->{x2}; |
100
|
138
|
100
|
|
|
|
413
|
$args->{max_x} = $args->{x1} > $args->{x2} ? $args->{x1} : $args->{x2}; |
101
|
138
|
|
|
|
|
418
|
$args->{shape_length} = $class->pythagorean($point1, $point2); |
102
|
138
|
|
|
|
|
2637
|
return $args; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |