X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FPolyline.pm;h=627fd81080b7bd69e95430d0436afcd86cb1996d;hb=93edf9c5c04a04fbd3c8dbf04eacaf66736ff6ee;hp=445beb55022d839f1e0be476f159a11813e60c39;hpb=3661d7849ae4636b74000e33e068493d90ed8337;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Polyline.pm b/lib/LaTeX/TikZ/Set/Polyline.pm index 445beb5..627fd81 100644 --- a/lib/LaTeX/TikZ/Set/Polyline.pm +++ b/lib/LaTeX/TikZ/Set/Polyline.pm @@ -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