X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPoint.pm;h=eee96b0fa55c97c0b98cc1994a2aed69f614169b;hb=99693e9864c02528a5eb76520bff25757f12ffd8;hp=c4749fe66ab879f51aa426fc3b01b0201621950e;hpb=19660696c832bcff26c87d371cccc4ffe118c782;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Point.pm b/lib/LaTeX/TikZ/Set/Point.pm index c4749fe..eee96b0 100644 --- a/lib/LaTeX/TikZ/Set/Point.pm +++ b/lib/LaTeX/TikZ/Set/Point.pm @@ -18,16 +18,26 @@ our $VERSION = '0.01'; use LaTeX::TikZ::Point; use Any::Moose; +use Any::Moose 'Util::TypeConstraints'; with 'LaTeX::TikZ::Set::Op'; has 'point' => ( is => 'ro', - does => 'LaTeX::TikZ::Point::Autocoerce', + isa => 'LaTeX::TikZ::Point::Autocoerce', required => 1, coerce => 1, + handles => [ qw/x y/ ], ); +coerce 'LaTeX::TikZ::Set::Point' + => from 'Any' + => via { __PACKAGE__->new(point => $_) }; + +coerce 'LaTeX::TikZ::Point::Autocoerce' + => from 'LaTeX::TikZ::Set::Point' + => via { $_->point }; + sub path { my ($set, $tikz) = @_; @@ -39,7 +49,10 @@ sub path { use LaTeX::TikZ::Interface point => sub { shift; - __PACKAGE__->new(point => @_ > 1 ? \@_ : $_[0] ); + my $point = @_ == 0 ? 0 + : @_ == 1 ? $_[0] + : \@_; + __PACKAGE__->new(point => $point); }; __PACKAGE__->meta->make_immutable;