]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Set/Path.pm
Just use Mouse instead of Any::Moose
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Path.pm
index 0b695c62c622cb27e30eeae6539716adb842ef2b..259e1ce24c0dce96eb6b00a50e4a32614e350493 100644 (file)
@@ -5,63 +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.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
-use Any::Moose;
-use Any::Moose 'Util::TypeConstraints'
-               => [ qw/subtype as where find_type_constraint/ ];
+=head1 DESCRIPTION
 
-with qw(
- LaTeX::TikZ::Set::Op
- LaTeX::TikZ::Set::Mutable
-);
+Paths are all the elements against which we can call the C<path> method.
 
-subtype 'LaTeX::TikZ::Set::Path::Elements'
-     => as 'Object'
-     => where { $_->does('LaTeX::TikZ::Set::Op') };
+=cut
 
-has '_ops' => (
- is       => 'ro',
- isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path::Elements]]',
- init_arg => 'ops',
- default  => sub { [ ] },
-);
+use Mouse::Role;
 
-sub ops { @{$_[0]->_ops} }
+=head1 RELATIONSHIPS
 
-my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements');
+This role consumes the L<LaTeX::TikZ::Set> role, and as such implements the L</draw> method.
 
-sub add {
- my $set = shift;
+=cut
 
- $ltspe_tc->assert_valid($_) for @_;
+with 'LaTeX::TikZ::Set';
 
- push @{$set->_ops}, @_;
+=head1 METHODS
 
- $set;
-}
+These methods are required by the interface :
+
+=over 4
+
+=item *
+
+C<path $formatter, $context>
+
+Returns the TikZ code that builds a path out of the current set object as a string formatted by the L<LaTeX::TikZ::Formatter> object C<$formatter>.
+The current evaluation context is passed as the L<LaTeX::TikZ::Context> object C<$context>.
+
+=item *
+
+C<begin>
+
+Returns a L<LaTeX::TikZ::Point> object pointing to the beginning of the path, or C<undef> if this path has no beginning.
 
-sub path {
+=item *
+
+C<end>
+
+A L<LaTeX::TikZ::Point> object pointing to the end of the path, or C<undef> if this path has no end.
+
+=back
+
+=cut
+
+requires qw<
+ path
+ begin
+ end
+>;
+
+=head2 C<draw>
+
+=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<LaTeX::TikZ>, L<LaTeX::TikZ::Set>.
 
 =head1 AUTHOR
 
@@ -88,4 +105,4 @@ This program is free software; you can redistribute it and/or modify it under th
 
 =cut
 
-1; # End of LaTeX::TikZ::Set::Path
+1; # End of LaTeX::TikZ::Set::Path;