X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPath.pm;h=f7a5fb21b684deb1afca328d216f41597d42db27;hb=b8f42942311854cb0ef8a3e34c0145846639cd2e;hp=7a8793d1232e9cd82167e273d2c3dbe74bd9d8de;hpb=e6c6fbca8df4f8df7bbce2eb98dd260ed51d9141;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Path.pm b/lib/LaTeX/TikZ/Set/Path.pm index 7a8793d..f7a5fb2 100644 --- a/lib/LaTeX/TikZ/Set/Path.pm +++ b/lib/LaTeX/TikZ/Set/Path.pm @@ -5,99 +5,65 @@ 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 LaTeX::TikZ::Interface; -use LaTeX::TikZ::Functor; +=head1 DESCRIPTION -use Any::Moose; -use Any::Moose 'Util::TypeConstraints' - => [ qw/subtype as where find_type_constraint/ ]; - -=head1 RELATIONSHIPS - -This class consumes the L and L roles, and as such implements the L and L methods. +Paths are all the elements against which we can call the C method. =cut -with qw( - LaTeX::TikZ::Set::Op - LaTeX::TikZ::Set::Mutable -); - -=head1 ATTRIBUTES +use Any::Moose 'Role'; -=head2 C +=head1 RELATIONSHIPS -The L objects that from the path. +This role consumes the L role, and as such implements the L method. =cut -subtype 'LaTeX::TikZ::Set::Path::Elements' - => as 'Object' - => where { $_->does('LaTeX::TikZ::Set::Op') }; - -has '_ops' => ( - is => 'ro', - isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path::Elements]]', - init_arg => 'ops', - default => sub { [ ] }, -); - -sub ops { @{$_[0]->_ops} } +with 'LaTeX::TikZ::Set'; =head1 METHODS -=head2 C +This method is required by the interface : -=cut +=over 4 -my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements'); +=item * -sub add { - my $set = shift; +C - $ltspe_tc->assert_valid($_) for @_; +Returns the TikZ code that builds a path out of the current set object as a string formatted by the L object C<$formatter>. - push @{$set->_ops}, @_; +=back - $set; -} +=cut -=head2 C +requires qw< + path +>; + +=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 ]) - } -); +=head1 SEE ALSO -__PACKAGE__->meta->make_immutable; +L, L. =head1 AUTHOR @@ -124,4 +90,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;