X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FLaTeX%2FTikZ%2FSet%2FPath.pm;h=a0b822618b57e55c96f07ebc0413661d397b22c8;hb=1be10f0f8ab18b5c559d8a48270dda1ebd2d78bc;hp=8cd762c34ef55df37281ddcacb3d8a75e5bc1d0a;hpb=f54cadb836315572aa2c4bcb16f221da1687df7a;p=perl%2Fmodules%2FLaTeX-TikZ.git
diff --git a/lib/LaTeX/TikZ/Set/Path.pm b/lib/LaTeX/TikZ/Set/Path.pm
index 8cd762c..a0b8226 100644
--- a/lib/LaTeX/TikZ/Set/Path.pm
+++ b/lib/LaTeX/TikZ/Set/Path.pm
@@ -5,7 +5,7 @@ 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
@@ -15,89 +15,70 @@ Version 0.02
our $VERSION = '0.02';
-use LaTeX::TikZ::Interface;
-use LaTeX::TikZ::Functor;
+=head1 DESCRIPTION
-use LaTeX::TikZ::Tools;
+Paths are all the elements against which we can call the C method.
-use Any::Moose;
+=cut
+
+use Mouse::Role;
=head1 RELATIONSHIPS
-This class consumes the L and L roles, and as such implements the L and L methods.
+This role consumes the L role, and as such implements the L method.
=cut
-with qw(
- LaTeX::TikZ::Set::Op
- LaTeX::TikZ::Set::Mutable
-);
+with 'LaTeX::TikZ::Set';
-=head1 ATTRIBUTES
+=head1 METHODS
-=head2 C
+These methods are required by the interface :
-The L objects that from the path.
+=over 4
-=cut
+=item *
-has '_ops' => (
- is => 'ro',
- isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]',
- init_arg => 'ops',
- default => sub { [ ] },
-);
+C
-sub ops { @{$_[0]->_ops} }
+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>.
-=head1 METHODS
+=item *
-=head2 C
+C
-=cut
+Returns a L object pointing to the beginning of the path, or C if this path has no beginning.
-my $ltso_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Op');
+=item *
-sub add {
- my $set = shift;
+C
- $ltso_tc->assert_valid($_) for @_;
+A L object pointing to the end of the path, or C if this path has no end.
- push @{$set->_ops}, @_;
+=back
- $set;
-}
+=cut
-=head2 C
+requires qw<
+ path
+ begin
+ end
+>;
+
+=head2 C
=cut
-sub path {
+sub draw {
my $set = shift;
- join ' ', map $_->path(@_), $set->ops;
+ [ "\\draw " . $set->path(@_) . ' ;' ];
}
-LaTeX::TikZ::Interface->register(
- path => sub {
- shift;
-
- __PACKAGE__->new(ops => \@_);
- },
-);
-
-LaTeX::TikZ::Functor->default_rule(
- (__PACKAGE__) => sub {
- my ($functor, $set, @args) = @_;
- $set->new(ops => [ map $_->$functor(@args), $set->ops ])
- }
-);
-
-__PACKAGE__->meta->make_immutable;
-
=head1 SEE ALSO
-L, L, L.
+L, L.
=head1 AUTHOR
@@ -118,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;