line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Line; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Line::VERSION = '1.0107'; |
3
|
2
|
|
|
2
|
|
778
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
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.0107 |
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
|
4
|
|
|
4
|
0
|
5247
|
my ($class, @args) = @_; |
83
|
|
|
|
|
|
|
##Upgrade to hashref |
84
|
4
|
50
|
|
|
|
52
|
my $args = @args % 2 ? $args[0] : { @args }; |
85
|
4
|
50
|
|
|
|
13
|
return $args unless exists $args->{transformer}; |
86
|
4
|
|
|
|
|
17
|
my $point1 = $args->{transformer}->transform([$args->{x1}, $args->{y1}]); |
87
|
4
|
|
|
|
|
784
|
my $point2 = $args->{transformer}->transform([$args->{x2}, $args->{y2}]); |
88
|
4
|
|
|
|
|
223
|
$args->{x1} = $point1->[0]; |
89
|
4
|
|
|
|
|
4
|
$args->{y1} = $point1->[1]; |
90
|
4
|
|
|
|
|
5
|
$args->{x2} = $point2->[0]; |
91
|
4
|
|
|
|
|
5
|
$args->{y2} = $point2->[1]; |
92
|
4
|
|
|
|
|
6
|
$args->{draw_start} = $point1; |
93
|
4
|
|
|
|
|
8
|
$args->{draw_end} = $point2; |
94
|
4
|
100
|
|
|
|
11
|
$args->{min_y} = $args->{y1} < $args->{y2} ? $args->{y1} : $args->{y2}; |
95
|
4
|
100
|
|
|
|
11
|
$args->{max_y} = $args->{y1} > $args->{y2} ? $args->{y1} : $args->{y2}; |
96
|
4
|
100
|
|
|
|
7
|
$args->{min_x} = $args->{x1} < $args->{x2} ? $args->{x1} : $args->{x2}; |
97
|
4
|
100
|
|
|
|
8
|
$args->{max_x} = $args->{x1} > $args->{x2} ? $args->{x1} : $args->{x2}; |
98
|
4
|
|
|
|
|
38
|
$args->{shape_length} = $class->pythagorean($point1, $point2); |
99
|
4
|
|
|
|
|
77
|
return $args; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |