line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::TikZ::Set::Polyline; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
57
|
use strict; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
355
|
|
4
|
10
|
|
|
10
|
|
54
|
use warnings; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
404
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
LaTeX::TikZ::Set::Polyline - A set object representing a possibly closed path composed of contiguous lines. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.02 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
66
|
use LaTeX::TikZ::Set::Point; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
255
|
|
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
10
|
|
54
|
use LaTeX::TikZ::Interface; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
214
|
|
21
|
10
|
|
|
10
|
|
52
|
use LaTeX::TikZ::Functor; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
230
|
|
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
10
|
|
56
|
use Any::Moose; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
256
|
|
24
|
10
|
|
|
10
|
|
4656
|
use Any::Moose 'Util::TypeConstraints'; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
43
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 RELATIONSHIPS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
with 'LaTeX::TikZ::Set::Op'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
subtype 'LaTeX::TikZ::Set::Polyline::Vertices' |
35
|
|
|
|
|
|
|
=> as 'ArrayRef[LaTeX::TikZ::Set::Point]' |
36
|
|
|
|
|
|
|
=> where { @$_ >= 2 } |
37
|
|
|
|
|
|
|
=> message { 'at least two LaTeX::TikZ::Set::Point objects are needed in order to build a polyline' }; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
coerce 'LaTeX::TikZ::Set::Polyline::Vertices' |
40
|
|
|
|
|
|
|
=> from 'ArrayRef[Any]' |
41
|
|
|
|
|
|
|
=> via { [ map LaTeX::TikZ::Set::Point->new(point => $_), @$_ ] }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 C<points> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The list of the successive vertices of the path. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has '_points' => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
isa => 'LaTeX::TikZ::Set::Polyline::Vertices', |
54
|
|
|
|
|
|
|
init_arg => 'points', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
coerce => 1, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
7
|
1
|
12
|
sub points { @{$_[0]->_points} } |
|
7
|
|
|
|
|
52
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 C<closed> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A boolean that indicates whether the path is closed or not. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has 'closed' => ( |
68
|
|
|
|
|
|
|
is => 'ro', |
69
|
|
|
|
|
|
|
isa => 'Bool', |
70
|
|
|
|
|
|
|
default => 0, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 C<path> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub path { |
80
|
7
|
|
|
7
|
1
|
14
|
my $set = shift; |
81
|
|
|
|
|
|
|
|
82
|
7
|
100
|
|
|
|
25
|
join ' -- ', map($_->path(@_), $set->points), |
83
|
|
|
|
|
|
|
($set->closed ? 'cycle' : ()); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
LaTeX::TikZ::Interface->register( |
87
|
|
|
|
|
|
|
polyline => sub { |
88
|
5
|
|
|
5
|
0
|
5548
|
shift; |
89
|
|
|
|
|
|
|
|
90
|
5
|
|
|
|
|
56
|
__PACKAGE__->new(points => \@_); |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
closed_polyline => sub { |
93
|
5
|
|
|
5
|
0
|
5673
|
shift; |
94
|
|
|
|
|
|
|
|
95
|
5
|
|
|
|
|
51
|
__PACKAGE__->new(points => \@_, closed => 1); |
96
|
|
|
|
|
|
|
}, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
LaTeX::TikZ::Functor->default_rule( |
100
|
|
|
|
|
|
|
(__PACKAGE__) => sub { |
101
|
|
|
|
|
|
|
my ($functor, $set, @args) = @_; |
102
|
|
|
|
|
|
|
$set->new( |
103
|
|
|
|
|
|
|
points => [ map $_->$functor(@args), $set->points ], |
104
|
|
|
|
|
|
|
closed => $set->closed, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Op>. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
You can contact me by mail or on C<irc.perl.org> (vincent). |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 BUGS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>. |
124
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SUPPORT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
perldoc LaTeX::TikZ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright 2010 Vincent Pit, all rights reserved. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; # End of LaTeX::TikZ::Set::Polyline |