X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FFormatter.pm;h=e06676affd631ee025852b30595eba295b8fee1c;hb=61a93a58351bf2d238dcf81a1a557112b0c0ee85;hp=86d1b14bd114884e67459a41892c5016d075693a;hpb=b8e5d217d4c1ac94edf4fc3e6492f411462bb31e;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Formatter.pm b/lib/LaTeX/TikZ/Formatter.pm index 86d1b14..e06676a 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 @@ -29,8 +29,8 @@ use LaTeX::TikZ::Interface; use LaTeX::TikZ::Tools; -use Any::Moose; -use Any::Moose 'Util::TypeConstraints'; +use Mouse; +use Mouse::Util::TypeConstraints; =head1 ATTRIBUTES @@ -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,10 +139,12 @@ sub id { join $;, map { defined() ? "$_" : '(undef)'; - } map($tikz->$_, qw/unit format scale width height/), $origin; + } map($tikz->$_, qw), $origin; } -=head2 C +=head2 C + + my ($header_lines, $mod_lines, $content_lines) = $formatter->render(@sets); Processes all the L objects given in C<@sets> to produce the actual TikZ code to insert in the LaTeX file. First, all the mods applied to the sets and their subsets are collected, and a declaration is emitted if needed for each of them by calling L. @@ -212,11 +214,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; }); @@ -298,7 +298,9 @@ sub render { return \@header, \@decls, @bodies; } -=head2 C +=head2 C + + my $physical_len = $formatter->len($logical_len); Format the given length according to the formatter options. @@ -312,7 +314,9 @@ sub len { sprintf $tikz->format . $tikz->unit, $len * $tikz->scale; } -=head2 C +=head2 C + + my $physical_angle = $formatter->angle($logical_angle); Format the given angle (in radians) according to the formatter options. @@ -328,7 +332,9 @@ sub angle { sprintf $tikz->format, POSIX::ceil($a); } -=head2 C