X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FChain.pm;h=eb5395f5ef27bf3b6216d38499d10414cb9dcdaf;hb=4ec204cfd114d9ce19fd616f093503c971b00a1f;hp=2c640c2821495cddc51ab9cb7a3e3db69bb21035;hpb=e8590b71a4239eabe4a13e86163b1ed8dad695ed;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Chain.pm b/lib/LaTeX/TikZ/Set/Chain.pm index 2c640c2..eb5395f 100644 --- a/lib/LaTeX/TikZ/Set/Chain.pm +++ b/lib/LaTeX/TikZ/Set/Chain.pm @@ -16,6 +16,7 @@ Version 0.02 our $VERSION = '0.02'; use LaTeX::TikZ::Set::Point; +use LaTeX::TikZ::Set::Raw; use LaTeX::TikZ::Interface; use LaTeX::TikZ::Functor; @@ -116,6 +117,18 @@ has 'connector' => ( coerce => 1, ); +=head2 C + +A boolean that indicates whether the path is a cycle or not. + +=cut + +has 'cycle' => ( + is => 'ro', + isa => 'Bool', + default => 0, +); + =head1 METHODS =head2 C @@ -139,7 +152,7 @@ sub add { =cut sub path { - my ($set, $tikz) = @_; + my $set = shift; my @kids = $set->kids; return '' unless @kids; @@ -147,15 +160,22 @@ sub path { my $conn = $set->connector; my $prev = $kids[0]; - my $path = $prev->path($tikz); + my $path = $prev->path(@_); + + if ($set->cycle) { + push @kids, LaTeX::TikZ::Set::Raw->new( + content => 'cycle', + ); + } + my $tikz = $_[0]; for my $i (1 .. $#kids) { my $next = $kids[$i]; my $link = $set->$conn($i - 1, $prev, $next, $tikz); confess('Invalid connector') unless defined $link and not blessed $link; $link = " $link "; $link =~ s/\s+/ /g; - $path .= $link . $next->path($tikz); + $path .= $link . $next->path(@_); $prev = $next; } @@ -223,6 +243,7 @@ LaTeX::TikZ::Functor->default_rule( $set->new( kids => [ map $_->$functor(@args), $set->kids ], connector => $set->connector, + cycle => $set->cycle, ); } );