X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FArrow.pm;fp=lib%2FLaTeX%2FTikZ%2FSet%2FArrow.pm;h=415adff5655ad2edda05c3610c127dec6366da9b;hb=af7d6a5aef3bf5fec0c187b3a13a14adc88251fd;hp=cc10eab2bd35bb85aed5b513a402f758854d1f4c;hpb=92147217516a40b35ca00c8e08939e8aa5478426;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Arrow.pm b/lib/LaTeX/TikZ/Set/Arrow.pm index cc10eab..415adff 100644 --- a/lib/LaTeX/TikZ/Set/Arrow.pm +++ b/lib/LaTeX/TikZ/Set/Arrow.pm @@ -21,33 +21,37 @@ use LaTeX::TikZ::Point; use LaTeX::TikZ::Set::Line; +use LaTeX::TikZ::Interface; + use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ]; my $ltp_tc = find_type_constraint('LaTeX::TikZ::Point::Autocoerce'); -use LaTeX::TikZ::Interface arrow => sub { - shift; - - Carp::confess('Not enough arguments') unless @_ >= 2; - - my $from = $ltp_tc->coerce(shift); - - my $to; - if ($_[0] eq 'dir') { - my $dir = $ltp_tc->coerce($_[1]); - $to = LaTeX::TikZ::Point->new( - x => $from->x + $dir->x, - y => $from->y + $dir->y, - ); - } else { - $to = $_[0]; - } - - LaTeX::TikZ::Set::Line->new( - from => $from, - to => $to, - )->mod('->'); -}; +LaTeX::TikZ::Interface->register( + arrow => sub { + shift; + + Carp::confess('Not enough arguments') unless @_ >= 2; + + my $from = $ltp_tc->coerce(shift); + + my $to; + if ($_[0] eq 'dir') { + my $dir = $ltp_tc->coerce($_[1]); + $to = LaTeX::TikZ::Point->new( + x => $from->x + $dir->x, + y => $from->y + $dir->y, + ); + } else { + $to = $_[0]; + } + + LaTeX::TikZ::Set::Line->new( + from => $from, + to => $to, + )->mod('->'); + }, +); =head1 AUTHOR