line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::TikZ::Set::Rectangle; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
40
|
use strict; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
295
|
|
4
|
10
|
|
|
10
|
|
33
|
use warnings; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
327
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
LaTeX::TikZ::Set::Rectangle - A set object representing a rectangle. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.03 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
34
|
use LaTeX::TikZ::Set::Point; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
141
|
|
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
10
|
|
28
|
use LaTeX::TikZ::Interface; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
118
|
|
21
|
10
|
|
|
10
|
|
42
|
use LaTeX::TikZ::Functor; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
143
|
|
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
10
|
|
29
|
use Mouse; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
37
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 RELATIONSHIPS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This class consumes the L role, and as such implements the L method. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with 'LaTeX::TikZ::Set::Path'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 C |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The first corner of the rectangle, as a L object. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'from' => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => 'LaTeX::TikZ::Set::Point', |
44
|
|
|
|
|
|
|
required => 1, |
45
|
|
|
|
|
|
|
coerce => 1, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The opposite endpoint of the rectangle, also as a L object. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'to' => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
isa => 'LaTeX::TikZ::Set::Point', |
57
|
|
|
|
|
|
|
required => 1, |
58
|
|
|
|
|
|
|
coerce => 1, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 C |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The algebraic width of the rectangle. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has 'width' => ( |
68
|
|
|
|
|
|
|
is => 'ro', |
69
|
|
|
|
|
|
|
isa => 'Num', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 C |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The algebraic height of the rectangle. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has 'height' => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
isa => 'Num', |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub path { |
90
|
14
|
|
|
14
|
1
|
16
|
my $set = shift; |
91
|
|
|
|
|
|
|
|
92
|
14
|
|
|
|
|
45
|
$set->from->path(@_) . ' rectangle ' . $set->to->path(@_); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
0
|
1
|
0
|
sub begin { $_[0]->from->begin } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 C |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
1
|
0
|
sub end { $_[0]->to->end } |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
108
|
|
|
|
|
|
|
my $tc1 = $meta->find_attribute_by_name('from')->type_constraint; |
109
|
|
|
|
|
|
|
my $tc2 = $meta->find_attribute_by_name('to')->type_constraint; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
around 'BUILDARGS' => sub { |
112
|
|
|
|
|
|
|
my $orig = shift; |
113
|
|
|
|
|
|
|
my $class = shift; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
if (@_ == 2 and $tc1->check($_[0]) and $tc2->check($_[1])) { |
116
|
|
|
|
|
|
|
my ($from, $to) = @_; |
117
|
|
|
|
|
|
|
@_ = ( |
118
|
|
|
|
|
|
|
from => $from, |
119
|
|
|
|
|
|
|
to => $to, |
120
|
|
|
|
|
|
|
width => $to->x - $from->x, |
121
|
|
|
|
|
|
|
height => $to->y - $from->y, |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
} else { |
124
|
|
|
|
|
|
|
my %args = @_; |
125
|
|
|
|
|
|
|
if (not exists $args{to} and exists $args{from}) { |
126
|
|
|
|
|
|
|
confess(<<' MSG') unless exists $args{width} and exists $args{height}; |
127
|
|
|
|
|
|
|
Attributes 'width' and 'height' are required when 'to' was not given |
128
|
|
|
|
|
|
|
MSG |
129
|
|
|
|
|
|
|
$args{from} = $tc1->coerce($args{from}); |
130
|
|
|
|
|
|
|
$meta->find_attribute_by_name($_)->type_constraint->assert_valid($args{$_}) |
131
|
|
|
|
|
|
|
for qw; |
132
|
|
|
|
|
|
|
my $p = $args{from}->point; |
133
|
|
|
|
|
|
|
$args{to} = LaTeX::TikZ::Point->new( |
134
|
|
|
|
|
|
|
x => $p->x + $args{width}, |
135
|
|
|
|
|
|
|
y => $p->y + $args{height}, |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
@_ = %args; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$class->$orig(@_); |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
LaTeX::TikZ::Interface->register( |
145
|
|
|
|
|
|
|
rectangle => sub { |
146
|
9
|
|
|
9
|
0
|
4409
|
shift; |
147
|
9
|
|
|
|
|
15
|
my ($p, $q) = @_; |
148
|
|
|
|
|
|
|
|
149
|
9
|
|
100
|
|
|
53
|
my $is_relative = !blessed($q) && ref($q) eq 'HASH'; |
150
|
|
|
|
|
|
|
|
151
|
9
|
100
|
|
|
|
71
|
__PACKAGE__->new( |
152
|
|
|
|
|
|
|
from => $p, |
153
|
|
|
|
|
|
|
($is_relative ? (map +($_ => $q->{$_}), qw) : (to => $q)), |
154
|
|
|
|
|
|
|
); |
155
|
|
|
|
|
|
|
}, |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
LaTeX::TikZ::Functor->default_rule( |
159
|
|
|
|
|
|
|
(__PACKAGE__) => sub { |
160
|
|
|
|
|
|
|
my ($functor, $set, @args) = @_; |
161
|
|
|
|
|
|
|
$set->new(map { $_ => $set->$_->$functor(@args) } qw) |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SEE ALSO |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L, L. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 BUGS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
180
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SUPPORT |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
perldoc LaTeX::TikZ |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; # End of LaTeX::TikZ::Set::Rectangle |