line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::TikZ::Set; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
36
|
use strict; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
282
|
|
4
|
10
|
|
|
10
|
|
31
|
use warnings; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
303
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
LaTeX::TikZ::Set - Base role for LaTeX::TikZ set objects. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.03 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
2668
|
use LaTeX::TikZ::Context; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
306
|
|
19
|
10
|
|
|
10
|
|
3165
|
use LaTeX::TikZ::Scope; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
228
|
|
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
45
|
use LaTeX::TikZ::Tools; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
148
|
|
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
10
|
|
30
|
use Mouse::Role; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
44
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 C |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Returns the list of the L objects associated with the current set. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has '_mods' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'Maybe[ArrayRef[LaTeX::TikZ::Mod]]', |
36
|
|
|
|
|
|
|
init_arg => 'mods', |
37
|
|
|
|
|
|
|
default => sub { [ ] }, |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
874
|
|
|
874
|
1
|
2429
|
sub mods { @{$_[0]->_mods} } |
|
874
|
|
|
|
|
4526
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This method is required by the interface : |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns an array reference of TikZ code lines required to effectively draw the current set object, formatted by the L object C<$formatter>. |
54
|
|
|
|
|
|
|
The current evaluation context is passed as the L object C<$context>. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
requires qw< |
61
|
|
|
|
|
|
|
draw |
62
|
|
|
|
|
|
|
>; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$set->mod(@mods) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Apply the given list of L objects to the current set. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $ltm_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod'); |
73
|
|
|
|
|
|
|
my $ltml_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Layer'); |
74
|
|
|
|
|
|
|
my $ltmc_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Clip'); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub mod { |
77
|
134
|
|
|
134
|
1
|
5243
|
my $set = shift; |
78
|
|
|
|
|
|
|
|
79
|
134
|
|
|
|
|
344
|
my @mods = map $ltm_tc->coerce($_), @_; |
80
|
134
|
|
|
|
|
3895
|
$ltm_tc->assert_valid($_) for @mods; |
81
|
|
|
|
|
|
|
|
82
|
133
|
|
|
|
|
3050
|
push @{$set->_mods}, @mods; |
|
133
|
|
|
|
|
410
|
|
83
|
|
|
|
|
|
|
|
84
|
133
|
|
|
|
|
389
|
$set; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
around 'draw' => sub { |
88
|
|
|
|
|
|
|
my ($orig, $set, $tikz, $pcxt) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $cxt = LaTeX::TikZ::Context->new( |
91
|
|
|
|
|
|
|
parent => $pcxt, |
92
|
|
|
|
|
|
|
mods => [ $set->mods ], |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $body = $set->$orig($tikz, $cxt); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my @mods = $cxt->effective_mods; |
98
|
|
|
|
|
|
|
if (@mods) { |
99
|
|
|
|
|
|
|
$body = LaTeX::TikZ::Scope->new( |
100
|
|
|
|
|
|
|
mods => [ map $_->apply($tikz), @mods ], |
101
|
|
|
|
|
|
|
body => $body, |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$body; |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 C |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$set->layer($layer) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Puts the current set in the corresponding layer. |
113
|
|
|
|
|
|
|
This is a shortcut for C<< $set->mod(Tikz->layer($layer)) >>. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub layer { |
118
|
5
|
|
|
5
|
1
|
3802
|
my $set = shift; |
119
|
|
|
|
|
|
|
|
120
|
5
|
100
|
|
|
|
14
|
return $set unless @_; |
121
|
|
|
|
|
|
|
|
122
|
4
|
|
|
|
|
6
|
my $layer = $_[0]; |
123
|
4
|
100
|
|
|
|
28
|
$set->mod( |
124
|
|
|
|
|
|
|
$ltml_tc->check($layer) ? $layer |
125
|
|
|
|
|
|
|
: LaTeX::TikZ::Mod::Layer->new(name => $layer) |
126
|
|
|
|
|
|
|
) |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 C |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$set->clip($path) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Clips the current set by the path given by C<$path>. |
134
|
|
|
|
|
|
|
This is a shortcut for C<< $set->mod(Tikz->clip($path)) >>. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub clip { |
139
|
20
|
|
|
20
|
1
|
1098
|
my $set = shift; |
140
|
|
|
|
|
|
|
|
141
|
20
|
50
|
|
|
|
34
|
return $set unless @_; |
142
|
|
|
|
|
|
|
|
143
|
20
|
50
|
|
|
|
159
|
$set->mod( |
144
|
|
|
|
|
|
|
map { |
145
|
20
|
|
|
|
|
26
|
$ltmc_tc->check($_) ? $_ : LaTeX::TikZ::Mod::Clip->new(clip => $_) |
146
|
|
|
|
|
|
|
} @_ |
147
|
|
|
|
|
|
|
) |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 BUGS |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
163
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SUPPORT |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
perldoc LaTeX::TikZ |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; # End of LaTeX::TikZ::Set |