X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FArrow.pm;h=eb651236a48ea63c4197dd75e643faff414d892d;hb=062ab95259610ce39ace60365b659d6113420ce7;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..eb65123 100644 --- a/lib/LaTeX/TikZ/Set/Arrow.pm +++ b/lib/LaTeX/TikZ/Set/Arrow.pm @@ -9,45 +9,53 @@ 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; +use Carp (); use LaTeX::TikZ::Point; use LaTeX::TikZ::Set::Line; -use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ]; +use LaTeX::TikZ::Interface; + +use Mouse::Util::TypeConstraints 'find_type_constraint'; my $ltp_tc = find_type_constraint('LaTeX::TikZ::Point::Autocoerce'); -use LaTeX::TikZ::Interface arrow => sub { - shift; +LaTeX::TikZ::Interface->register( + arrow => sub { + shift; + + Carp::confess('Not enough arguments') unless @_ >= 2; + + my $from = $ltp_tc->coerce(shift); - Carp::confess('Not enough arguments') unless @_ >= 2; + 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]; + } - my $from = $ltp_tc->coerce(shift); + LaTeX::TikZ::Set::Line->new( + from => $from, + to => $to, + )->mod('->'); + }, +); - 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]; - } +=head1 SEE ALSO - LaTeX::TikZ::Set::Line->new( - from => $from, - to => $to, - )->mod('->'); -}; +L, L. =head1 AUTHOR @@ -68,7 +76,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2010 Vincent Pit, all rights reserved. +Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.