]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Set/Chain.pm
Reimplement LT::Set::Polyline as a child class of LT::Set::Chain
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Chain.pm
index 2c640c2821495cddc51ab9cb7a3e3db69bb21035..d1022f842d4527513b3b9745a6a83b8d233f7bdf 100644 (file)
@@ -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<cycle>
+
+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<add>
@@ -149,6 +162,12 @@ sub path {
  my $prev  = $kids[0];
  my $path  = $prev->path($tikz);
 
+ if ($set->cycle) {
+  push @kids, LaTeX::TikZ::Set::Raw->new(
+   content => 'cycle',
+  );
+ }
+
  for my $i (1 .. $#kids) {
   my $next = $kids[$i];
   my $link = $set->$conn($i - 1, $prev, $next, $tikz);
@@ -223,6 +242,7 @@ LaTeX::TikZ::Functor->default_rule(
   $set->new(
    kids      => [ map $_->$functor(@args), $set->kids ],
    connector => $set->connector,
+   cycle     => $set->cycle,
   );
  }
 );