X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPolyline.pm;h=427a5d6ead7a7543c1b8b9695a24dbe31f799013;hb=062ab95259610ce39ace60365b659d6113420ce7;hp=e8e0ee0fe96e97c688e77a7d734c3305642583cf;hpb=7f9973057cc57660599aa4a093718cf343a48198;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Polyline.pm b/lib/LaTeX/TikZ/Set/Polyline.pm index e8e0ee0..427a5d6 100644 --- a/lib/LaTeX/TikZ/Set/Polyline.pm +++ b/lib/LaTeX/TikZ/Set/Polyline.pm @@ -20,8 +20,8 @@ use LaTeX::TikZ::Set::Point; use LaTeX::TikZ::Interface; use LaTeX::TikZ::Functor; -use Any::Moose; -use Any::Moose 'Util::TypeConstraints'; +use Mouse; +use Mouse::Util::TypeConstraints; =head1 RELATIONSHIPS @@ -56,14 +56,30 @@ has '+_kids' => ( coerce => 1, ); +=head2 C + +A boolean that indicates whether the polyline is closed or not. + +=cut + +has 'closed' => ( + is => 'ro', + isa => 'Bool', + required => 1, + default => 0, +); + sub points { @{$_[0]->_kids} } around 'BUILDARGS' => sub { my ($orig, $class, %args) = @_; + delete $args{cycle}; + $class->$orig( %args, connector => '--', + cycle => $args{closed}, ); }; @@ -71,18 +87,31 @@ LaTeX::TikZ::Interface->register( polyline => sub { shift; - __PACKAGE__->new(points => \@_); + __PACKAGE__->new( + points => \@_, + closed => 0, + ); }, closed_polyline => sub { shift; __PACKAGE__->new( points => \@_, - cycle => 1 + closed => 1, ); }, ); +LaTeX::TikZ::Functor->default_rule( + (__PACKAGE__) => sub { + my ($functor, $set, @args) = @_; + $set->new( + points => [ map $_->$functor(@args), $set->kids ], + closed => $set->closed, + ); + } +); + __PACKAGE__->meta->make_immutable; =head1 SEE ALSO @@ -108,7 +137,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.