LaTeX::TikZ::Formatter - LaTeX::TikZ formatter object.
Version 0.03
A formatter object turns a LaTeX::TikZ::Set tree into the actual TikZ code, depending on some parameters such as the scale, the unit or the origin.
unit
The unit in which lengths are printed. Valid units are cm for centimeters and pt for points.
cm
pt
Defaults to cm.
format
The format used to print the numbers.
Defaults to %s.
%s
scale
The scale of the drawing.
Defaults to 1.
1
width
The width of the drawing area.
Defaults to undef for none.
undef
height
The height of the drawing area.
origin
A point coerced into a LaTeX::TikZ::Point object that represents the logical origin of the printed area. If "width" and "height" are set, the canvas will be equivalent to a rectangle whose lower left corner at -$origin and of given width and length.
-$origin
Defaults to (0, 0), meaning that the drawing area goes from (0, 0) to ($width, $height).
(0, 0)
($width, $height)
id
An unique identifier of the formatter object.
render
my ($header_lines, $mod_lines, $content_lines) = $formatter->render(@sets);
Processes all the LaTeX::TikZ::Set objects given in @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 "declare" in LaTeX::TikZ::Mod. Then, the image code is generated for each set.
@sets
This method returns a list of array references :
The first one contains the header lines to include between the \documentclass and the \begin{document}.
\documentclass
\begin{document}
The second one contains the mod declaration lines to put inside the document, between \begin{document} and \end{document}.
\end{document}
Finally, there's one array reference for each given TikZ set, which contain the lines for the actual TikZ pictures.
The lines returned by "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}", );
len
my $physical_len = $formatter->len($logical_len);
Format the given length according to the formatter options.
angle
my $physical_angle = $formatter->angle($logical_angle);
Format the given angle (in radians) according to the formatter options.
label
my $label = $formatter->label($name, $pos);
Returns the TikZ code for a point labeled $name at position $pos according to the formatter options.
$name
$pos
thickness
Format the given line thickness according to the formatter options.
LaTeX::TikZ.
Vincent Pit, <perl at profvince.com>, http://www.profvince.com.
<perl at profvince.com>
You can contact me by mail or on irc.perl.org (vincent).
irc.perl.org
Please report any bugs or feature requests to bug-latex-tikz at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-latex-tikz at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc LaTeX::TikZ
Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install LaTeX::TikZ, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LaTeX::TikZ
CPAN shell
perl -MCPAN -e shell install LaTeX::TikZ
For more information on module installation, please visit the detailed CPAN module installation guide.