]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Set/Line.pm
faa4ccb22f018411b8febb610874b0761e9b2327
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Line.pm
1 package LaTeX::TikZ::Set::Line;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Set::Line - A set object representing a line.
9
10 =head1 VERSION
11
12 Version 0.02
13
14 =cut
15
16 our $VERSION = '0.02';
17
18 use LaTeX::TikZ::Set::Point;
19
20 use LaTeX::TikZ::Interface;
21 use LaTeX::TikZ::Functor;
22
23 use Any::Moose;
24
25 =head1 RELATIONSHIPS
26
27 This class consumes the L<LaTeX::TikZ::Set::Path> role, and as such implements the L</path> method.
28
29 =cut
30
31 with 'LaTeX::TikZ::Set::Path';
32
33 =head1 ATTRIBUTES
34
35 =head2 C<from>
36
37 The first endpoint of the line, as a L<LaTeX::TikZ::Set::Point> 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<to>
49
50 The second endpoint of the line, also as a L<LaTeX::TikZ::Set::Point> 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 =head1 METHODS
62
63 =head2 C<path>
64
65 =cut
66
67 sub path {
68  my $set = shift;
69
70  $set->from->path(@_) . ' -- ' . $set->to->path(@_);
71 }
72
73 =head2 C<begin>
74
75 =cut
76
77 sub begin { $_[0]->from->begin }
78
79 =head2 C<end>
80
81 =cut
82
83 sub end { $_[0]->to->end }
84
85 LaTeX::TikZ::Interface->register(
86  line => sub {
87   shift;
88
89   __PACKAGE__->new(from => $_[0], to => $_[1]);
90  },
91 );
92
93 LaTeX::TikZ::Functor->default_rule(
94  (__PACKAGE__) => sub {
95   my ($functor, $set, @args) = @_;
96   $set->new(map { $_ => $set->$_->$functor(@args) } qw<from to>)
97  }
98 );
99
100 __PACKAGE__->meta->make_immutable;
101
102 =head1 SEE ALSO
103
104 L<LaTeX::TikZ>, L<LaTeX::TikZ::Set::Path>.
105
106 =head1 AUTHOR
107
108 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
109
110 You can contact me by mail or on C<irc.perl.org> (vincent).
111
112 =head1 BUGS
113
114 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>.
115 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
116
117 =head1 SUPPORT
118
119 You can find documentation for this module with the perldoc command.
120
121     perldoc LaTeX::TikZ
122
123 =head1 COPYRIGHT & LICENSE
124
125 Copyright 2010 Vincent Pit, all rights reserved.
126
127 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
128
129 =cut
130
131 1; # End of LaTeX::TikZ::Set::Line