From: Vincent Pit Date: Fri, 23 Jul 2010 19:51:42 +0000 (+0200) Subject: More docs for LaTeX::TikZ::Formatter X-Git-Tag: v0.02~31 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=699a6616fb6dea9ba01c0ce6d6fdeca968868a36;p=perl%2Fmodules%2FLaTeX-TikZ.git More docs for LaTeX::TikZ::Formatter --- diff --git a/lib/LaTeX/TikZ/Formatter.pm b/lib/LaTeX/TikZ/Formatter.pm index bd637e8..368e0af 100644 --- a/lib/LaTeX/TikZ/Formatter.pm +++ b/lib/LaTeX/TikZ/Formatter.pm @@ -36,6 +36,11 @@ use Any::Moose 'Util::TypeConstraints'; =head2 C +The unit in which lengths are printed. +Valid units are C for centimeters and C for points. + +Defaults to C. + =cut has 'unit' => ( @@ -46,6 +51,10 @@ has 'unit' => ( =head2 C +The format used to print the numbers. + +Defaults to C<%s>. + =cut has 'format' => ( @@ -56,6 +65,10 @@ has 'format' => ( =head2 C +The scale of the drawing. + +Defaults to C<1>. + =cut has 'scale' => ( @@ -66,6 +79,10 @@ has 'scale' => ( =head2 C +The width of the drawing area. + +Defaults to C for none. + =cut has 'width' => ( @@ -75,6 +92,10 @@ has 'width' => ( =head2 C +The height of the drawing area. + +Defaults to C for none. + =cut has 'height' => ( @@ -84,6 +105,11 @@ has 'height' => ( =head2 C +A point coerced into a L object that represents the logical origin of the printed area. +If L and L are set, the canvas will be equivalent to a rectangle whose lower left corner at C<-$origin> and of given width and length. + +Defaults to C<(0, 0)>, meaning that the drawing area goes from C<(0, 0)> to C<($width, $height)>. + =cut has 'origin' => ( @@ -96,6 +122,8 @@ has 'origin' => ( =head2 C +An unique identifier of the formatter object. + =cut sub id { @@ -114,7 +142,31 @@ sub id { } map($tikz->$_, qw/unit format scale width height/), $origin; } -=head2 C +=head2 C + +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. +Then, the image code is generated for each set. + +This method returns a list of array references : + +=over 4 + +=item * + +The first one contains the header lines to include between the C<\documentclass> and the C<\begin{document}>. + +=item * + +The second one contains the mod declaration lines to put inside the document, between C<\begin{document}> and C<\end{document}>. + +=item * + +Finally, there's one array reference for each given TikZ set, which contain the lines for the actual TikZ pictures. + +=back + + my ($header, $declarations, $seq1_body, $seq2_body) = $formatter->render($set1, $set2); =cut @@ -225,7 +277,9 @@ sub render { return \@header, \@decls, @bodies; } -=head2 C +=head2 C + +Format the given length according to the formatter options. =cut @@ -237,7 +291,9 @@ sub len { sprintf $tikz->format . $tikz->unit, $len * $tikz->scale; } -=head2 C +=head2 C + +Format the given angle (in radians) according to the formatter options. =cut @@ -251,7 +307,9 @@ sub angle { sprintf $tikz->format, POSIX::ceil($a); } -=head2 C