]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Set/Point.pm
Allow a bare Tikz->point for 0
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Point.pm
index 58fb28c741a073b565512841ecba24a17a994abb..868fd5b1d7adfd355c9a360e414672a43e9a3d42 100644 (file)
@@ -18,16 +18,25 @@ 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,
 );
 
+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 +48,10 @@ sub path {
 use LaTeX::TikZ::Interface point => sub {
  shift;
 
- __PACKAGE__->new(point => $_[0]);
+ my $point = @_ == 0 ? 0
+                     : @_ == 1 ? $_[0]
+                               : \@_;
+ __PACKAGE__->new(point => $point);
 };
 
 __PACKAGE__->meta->make_immutable;