X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FFormatter.pm;h=bd637e848ce2ccc7d439d522742570e54e29fc07;hb=0f9d7c1a2d11bc7001fe450cb2086e67c13a39e9;hp=efa7dc6ed1da9c6558a18a02940163bdaa3d55b7;hpb=ee0f9123624eb8e48675f80303ed436b9a94e348;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Formatter.pm b/lib/LaTeX/TikZ/Formatter.pm index efa7dc6..bd637e8 100644 --- a/lib/LaTeX/TikZ/Formatter.pm +++ b/lib/LaTeX/TikZ/Formatter.pm @@ -15,6 +15,12 @@ Version 0.01 our $VERSION = '0.01'; +=head1 DESCRIPTION + +A formatter object turns a L tree into the actual TikZ code, depending on some parameters such as the scale, the unit or the origin. + +=cut + use Sub::Name (); use LaTeX::TikZ::Point; @@ -26,40 +32,72 @@ use LaTeX::TikZ::Tools; use Any::Moose; use Any::Moose 'Util::TypeConstraints'; +=head1 ATTRIBUTES + +=head2 C + +=cut + has 'unit' => ( is => 'ro', isa => enum([ qw/cm pt/ ]), default => 'cm', ); +=head2 C + +=cut + has 'format' => ( is => 'ro', isa => 'Str', default => '%s', ); +=head2 C + +=cut + has 'scale' => ( is => 'rw', isa => 'Num', default => 1, ); +=head2 C + +=cut + has 'width' => ( is => 'rw', isa => 'Maybe[Num]', ); +=head2 C + +=cut + has 'height' => ( is => 'rw', isa => 'Maybe[Num]', ); +=head2 C + +=cut + has 'origin' => ( is => 'rw', isa => 'LaTeX::TikZ::Point::Autocoerce', coerce => 1, ); +=head1 METHODS + +=head2 C + +=cut + sub id { my $tikz = shift; @@ -76,6 +114,10 @@ sub id { } map($tikz->$_, qw/unit format scale width height/), $origin; } +=head2 C + +=cut + my $find_mods = do { our %seen; @@ -183,6 +225,10 @@ sub render { return \@header, \@decls, @bodies; } +=head2 C + +=cut + sub len { my ($tikz, $len) = @_; @@ -191,6 +237,10 @@ sub len { sprintf $tikz->format . $tikz->unit, $len * $tikz->scale; } +=head2 C + +=cut + sub angle { my ($tikz, $a) = @_; @@ -201,6 +251,10 @@ sub angle { sprintf $tikz->format, POSIX::ceil($a); } +=head2 C