X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLaTeX-TikZ.git;a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FFormatter.pm;h=afdbd388c93d3aa8f36f74b3342c581be61dacc1;hp=368e0afea2475dc24b6c86dc636c9f0ee026c277;hb=1c53f7e28198adfb2905667acd5741f163832d7b;hpb=699a6616fb6dea9ba01c0ce6d6fdeca968868a36 diff --git a/lib/LaTeX/TikZ/Formatter.pm b/lib/LaTeX/TikZ/Formatter.pm index 368e0af..afdbd38 100644 --- a/lib/LaTeX/TikZ/Formatter.pm +++ b/lib/LaTeX/TikZ/Formatter.pm @@ -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. has 'unit' => ( is => 'ro', - isa => enum([ qw/cm pt/ ]), + isa => enum([ qw ]), 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; $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), $origin; } =head2 C @@ -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 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; });