]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Formatter.pm
Rename LT::Set::Mutable to ::Container
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Formatter.pm
index 368e0afea2475dc24b6c86dc636c9f0ee026c277..afdbd388c93d3aa8f36f74b3342c581be61dacc1 100644 (file)
@@ -9,11 +9,11 @@ LaTeX::TikZ::Formatter - LaTeX::TikZ formatter object.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 =head1 DESCRIPTION
 
@@ -45,7 +45,7 @@ Defaults to C<cm>.
 
 has 'unit' => (
  is      => 'ro',
- isa     => enum([ qw/cm pt/ ]),
+ isa     => enum([ qw<cm pt> ]),
  default => 'cm',
 );
 
@@ -131,7 +131,7 @@ sub id {
 
  my $origin = $tikz->origin;
  if (defined $origin) {
-  my ($x, $y) = map $origin->$_, qw/x y/;
+  my ($x, $y) = map $origin->$_, qw<x y>;
   $origin = "($x;$y)";
  } else {
   $origin = "(0;0)";
@@ -139,7 +139,7 @@ sub id {
 
  join $;, map {
   defined() ? "$_" : '(undef)';
- } map($tikz->$_, qw/unit format scale width height/), $origin;
+ } map($tikz->$_, qw<unit format scale width height>), $origin;
 }
 
 =head2 C<render @sets>
@@ -166,7 +166,28 @@ Finally, there's one array reference for each given TikZ set, which contain the
 
 =back
 
-    my ($header, $declarations, $seq1_body, $seq2_body) = $formatter->render($set1, $set2);
+The lines returned by L</render> don't end with a line feed.
+
+    my ($header, $declarations, $set1_body, $set2_body) = $formatter->render($set1, $set2);
+
+    open my $tex, '>', 'test.tex' or die "open('>test.tex'): $!";
+
+    print $tex "$_\n" for (
+     "\\documentclass[12pt]{article}",
+     @$header,
+     "\\begin{document}",
+      "\\pagestyle{empty}",
+      @$declarations,
+      "First set :"
+      "\\begin{center}",
+       @$set1_body,
+      "\\end{center}",
+      "Second set :"
+      "\\begin{center}",
+       @$set2_body,
+      "\\end{center}",
+     "\\end{document}",
+    );
 
 =cut
 
@@ -191,11 +212,9 @@ my $find_mods = do {
     }
    }
 
-   my @subsets = $set->isa('LaTeX::TikZ::Set::Sequence')
+   my @subsets = $set->does('LaTeX::TikZ::Set::Container')
                  ? $set->kids
-                 : $set->isa('LaTeX::TikZ::Set::Path')
-                   ? $set->ops
-                   : ();
+                 : ();
 
    $find_mods_rec->($_, $layers, $others) for @subsets;
   });