X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPath.pm;h=9dbc902eaa70e0d3a035412660180a3c753216da;hb=4f696c03a66ef6b52ee7b9b3c74a71d5abc64f7e;hp=319298b3bd518dd87a2a213dff4910b3247f499c;hpb=e8f0879ade07eed4f58cd52c0771f4e1ecc90b09;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Path.pm b/lib/LaTeX/TikZ/Set/Path.pm index 319298b..9dbc902 100644 --- a/lib/LaTeX/TikZ/Set/Path.pm +++ b/lib/LaTeX/TikZ/Set/Path.pm @@ -5,59 +5,80 @@ use warnings; =head1 NAME -LaTeX::TikZ::Set::Path - A set object representing a path. +LaTeX::TikZ::Set::Path - A role for set objects that can be part of a path. =head1 VERSION -Version 0.01 +Version 0.03 =cut -our $VERSION = '0.01'; +our $VERSION = '0.03'; -use LaTeX::TikZ::Tools; +=head1 DESCRIPTION -use Any::Moose; +Paths are all the elements against which we can call the C method. -with qw( - LaTeX::TikZ::Set::Op - LaTeX::TikZ::Set::Mutable -); +=cut -has '_ops' => ( - is => 'ro', - isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]', - init_arg => 'ops', - default => sub { [ ] }, -); +use Mouse::Role; -sub ops { @{$_[0]->_ops} } +=head1 RELATIONSHIPS -my $ltso_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Op'); +This role consumes the L role, and as such implements the L method. -sub add { - my $set = shift; +=cut - $ltso_tc->check($_) for @_; +with 'LaTeX::TikZ::Set'; - push @{$_[0]->_ops}, @_; +=head1 METHODS - $set; -} +These methods are required by the interface : + +=over 4 + +=item * + +C + +Returns the TikZ code that builds a path out of the current set object as a string formatted by the L object C<$formatter>. +The current evaluation context is passed as the L object C<$context>. + +=item * + +C + +Returns a L object pointing to the beginning of the path, or C if this path has no beginning. -sub path { +=item * + +C + +A L object pointing to the end of the path, or C if this path has no end. + +=back + +=cut + +requires qw< + path + begin + end +>; + +=head2 C + +=cut + +sub draw { my $set = shift; - join ' ', map $_->path(@_), $set->ops; + [ "\\draw " . $set->path(@_) . ' ;' ]; } -use LaTeX::TikZ::API path => sub { - shift; - - __PACKAGE__->new(ops => \@_); -}; +=head1 SEE ALSO -__PACKAGE__->meta->make_immutable; +L, L. =head1 AUTHOR @@ -78,10 +99,10 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2010 Vincent Pit, all rights reserved. +Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut -1; # End of LaTeX::TikZ::Set::Path +1; # End of LaTeX::TikZ::Set::Path;