X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FLine.pm;h=ffe5975c89a27be0db00f3ec03860b0903fb1829;hb=af7d6a5aef3bf5fec0c187b3a13a14adc88251fd;hp=13c4618eb7d7b97e476c6942c90dcab19869be16;hpb=98f997b4a99a2d7cb6ce6bed78f0be22361ad909;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Line.pm b/lib/LaTeX/TikZ/Set/Line.pm index 13c4618..ffe5975 100644 --- a/lib/LaTeX/TikZ/Set/Line.pm +++ b/lib/LaTeX/TikZ/Set/Line.pm @@ -17,6 +17,9 @@ our $VERSION = '0.01'; use LaTeX::TikZ::Set::Point; +use LaTeX::TikZ::Interface; +use LaTeX::TikZ::Functor; + use Any::Moose; with 'LaTeX::TikZ::Set::Op'; @@ -41,11 +44,20 @@ sub path { $set->from->path(@_) . ' -- ' . $set->to->path(@_); } -use LaTeX::TikZ::Interface line => sub { - shift; +LaTeX::TikZ::Interface->register( + line => sub { + shift; + + __PACKAGE__->new(from => $_[0], to => $_[1]); + }, +); - __PACKAGE__->new(from => $_[0], to => $_[1]); -}; +LaTeX::TikZ::Functor->default_rule( + (__PACKAGE__) => sub { + my ($functor, $set, @args) = @_; + $set->new(map { $_ => $set->$_->$functor(@args) } qw/from to/) + } +); __PACKAGE__->meta->make_immutable;