has 'origin' => (
is => 'rw',
- isa => 'Maybe[LaTeX::TikZ::Point::Autocoerce]',
+ isa => 'LaTeX::TikZ::Point::Autocoerce',
coerce => 1,
);
sub id {
my $tikz = shift;
+ my $origin = $tikz->origin;
+ if (defined $origin) {
+ my ($x, $y) = map $origin->$_, qw/x y/;
+ $origin = "($x;$y)";
+ } else {
+ $origin = "(0;0)";
+ }
+
join $;, map {
- my $val = $tikz->$_;
- defined($val) ? "$val" : '(undef)';
- } qw/unit format scale width height origin/;
+ defined() ? "$_" : '(undef)';
+ } map($tikz->$_, qw/unit format scale width height/), $origin;
}
my $find_mods = do {
});
};
+my $translate;
+
sub render {
my $tikz = shift;
kids => \@_,
);
+ unless ($translate) {
+ require LaTeX::TikZ::Functor;
+ $translate = LaTeX::TikZ::Functor->new(
+ rules => [
+ 'LaTeX::TikZ::Set::Point' => sub {
+ my ($functor, $set, $v) = @_;
+
+ $set->new(
+ point => [
+ $set->x + $v->x,
+ $set->y + $v->y,
+ ],
+ label => $set->label,
+ pos => $set->pos,
+ );
+ },
+ ],
+ );
+ }
+
+ my $origin = $tikz->origin;
+ $seq = $seq->$translate($origin) if defined $origin;
+
my (@layers, @other_mods);
$find_mods->($seq, \@layers, \@other_mods);