X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FArrow.pm;h=d870cafb90576db72eb60a04dfea4ae77b55f11c;hb=f54cadb836315572aa2c4bcb16f221da1687df7a;hp=cc10eab2bd35bb85aed5b513a402f758854d1f4c;hpb=92f8566cc72a8bfded5c55589030ddab5f215bd6;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Arrow.pm b/lib/LaTeX/TikZ/Set/Arrow.pm index cc10eab..d870caf 100644 --- a/lib/LaTeX/TikZ/Set/Arrow.pm +++ b/lib/LaTeX/TikZ/Set/Arrow.pm @@ -9,11 +9,11 @@ LaTeX::TikZ::Set::Arrow - A combined set object representing an arrow. =head1 VERSION -Version 0.01 +Version 0.02 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; use Carp; @@ -21,33 +21,41 @@ 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 SEE ALSO + +L, L. =head1 AUTHOR