our $VERSION = '0.01';
+=head1 DESCRIPTION
+
+A formatter object turns a L<LaTeX::TikZ::Set> 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;
use Any::Moose;
use Any::Moose 'Util::TypeConstraints';
+=head1 ATTRIBUTES
+
+=head2 C<unit>
+
+=cut
+
has 'unit' => (
is => 'ro',
isa => enum([ qw/cm pt/ ]),
default => 'cm',
);
+=head2 C<format>
+
+=cut
+
has 'format' => (
is => 'ro',
isa => 'Str',
default => '%s',
);
+=head2 C<scale>
+
+=cut
+
has 'scale' => (
is => 'rw',
isa => 'Num',
default => 1,
);
+=head2 C<width>
+
+=cut
+
has 'width' => (
is => 'rw',
isa => 'Maybe[Num]',
);
+=head2 C<height>
+
+=cut
+
has 'height' => (
is => 'rw',
isa => 'Maybe[Num]',
);
+=head2 C<origin>
+
+=cut
+
has 'origin' => (
is => 'rw',
isa => 'LaTeX::TikZ::Point::Autocoerce',
coerce => 1,
);
+=head1 METHODS
+
+=head2 C<id>
+
+=cut
+
sub id {
my $tikz = shift;
} map($tikz->$_, qw/unit format scale width height/), $origin;
}
+=head2 C<render>
+
+=cut
+
my $find_mods = do {
our %seen;
return \@header, \@decls, @bodies;
}
+=head2 C<len>
+
+=cut
+
sub len {
my ($tikz, $len) = @_;
sprintf $tikz->format . $tikz->unit, $len * $tikz->scale;
}
+=head2 C<angle>
+
+=cut
+
sub angle {
my ($tikz, $a) = @_;
sprintf $tikz->format, POSIX::ceil($a);
}
+=head2 C<label>
+
+=cut
+
sub label {
my ($tikz, $name, $pos) = @_;
"node[scale=$scale,$pos] {$name}";
}
+=head2 C<thickness>
+
+=cut
+
sub thickness {
my ($tikz, $width) = @_;