line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Rect; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Rect::VERSION = '1.0107'; |
3
|
3
|
|
|
3
|
|
1131
|
use Moo; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'SVG::Estimate::Shape'; |
6
|
|
|
|
|
|
|
with 'SVG::Estimate::Role::ArgsWithUnits'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
SVG::Estimate::Rect - Handles estimating rectangles. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 1.0107 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $rect = SVG::Estimate::Rect->new( |
19
|
|
|
|
|
|
|
transformer => $transform, |
20
|
|
|
|
|
|
|
start_point => [45,13], |
21
|
|
|
|
|
|
|
x => 3, |
22
|
|
|
|
|
|
|
y => 6, |
23
|
|
|
|
|
|
|
width => 11.76, |
24
|
|
|
|
|
|
|
height => 15.519, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $length = $rect->length; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 INHERITANCE |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This class extends L. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new() |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Constructor. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item x |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Float representing the top left corner x. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item y |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Float representing the top left corner y. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item width |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Float representing the width of the box. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item height |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Float representing the height of the box. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has x => ( |
62
|
|
|
|
|
|
|
is => 'ro', |
63
|
|
|
|
|
|
|
default => sub { 0 }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has y => ( |
67
|
|
|
|
|
|
|
is => 'ro', |
68
|
|
|
|
|
|
|
default => sub { 0 }, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has width => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
required => 1, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has height => ( |
77
|
|
|
|
|
|
|
is => 'ro', |
78
|
|
|
|
|
|
|
required => 1, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub BUILDARGS { |
82
|
|
|
|
|
|
|
my ($class, @args) = @_; |
83
|
|
|
|
|
|
|
##Upgrade to hashref |
84
|
|
|
|
|
|
|
my $args = @args % 2 ? $args[0] : { @args }; |
85
|
|
|
|
|
|
|
my $origin = [ $args->{x}, $args->{y} ]; |
86
|
|
|
|
|
|
|
my $opposite = [ $args->{x} + $args->{width}, $args->{y} + $args->{height} ]; |
87
|
|
|
|
|
|
|
if ($args->{transformer}->has_transforms) { |
88
|
|
|
|
|
|
|
$origin = $args->{transformer}->transform($origin); |
89
|
|
|
|
|
|
|
$opposite = $args->{transformer}->transform($opposite); |
90
|
|
|
|
|
|
|
$args->{x} = $origin->[0] < $opposite->[0] ? $origin->[0] : $opposite->[0]; |
91
|
|
|
|
|
|
|
$args->{y} = $origin->[1] < $opposite->[1] ? $origin->[1] : $opposite->[1]; |
92
|
|
|
|
|
|
|
$args->{width} = abs($opposite->[0] - $origin->[0]); |
93
|
|
|
|
|
|
|
$args->{height} = abs($opposite->[1] - $origin->[1]); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
$args->{draw_start} = $origin; |
96
|
|
|
|
|
|
|
$args->{draw_end} = $origin; |
97
|
|
|
|
|
|
|
my $disabled = $args->{width} == 0 || $args->{height} == 0; |
98
|
|
|
|
|
|
|
$args->{shape_length} = $disabled ? 0 : ($args->{width} + $args->{height}) * 2; |
99
|
|
|
|
|
|
|
$args->{min_x} = $origin->[0]; |
100
|
|
|
|
|
|
|
$args->{min_y} = $origin->[1]; |
101
|
|
|
|
|
|
|
$args->{max_x} = $opposite->[0]; |
102
|
|
|
|
|
|
|
$args->{max_y} = $opposite->[1]; |
103
|
|
|
|
|
|
|
return $args; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub args_with_units { |
107
|
7
|
|
|
7
|
0
|
14
|
return qw/width height/; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |