my $translate;
sub render {
- my $tikz = shift;
-
- my $seq = LaTeX::TikZ::Set::Sequence->new(
- kids => \@_,
- );
+ my ($tikz, @sets) = @_;
unless ($translate) {
require LaTeX::TikZ::Functor;
}
my $origin = $tikz->origin;
- $seq = $seq->$translate($origin) if defined $origin;
+ if (defined $origin) {
+ @sets = map $_->$translate($origin), @sets;
+ }
my (@layers, @other_mods);
+ my $seq = LaTeX::TikZ::Set::Sequence->new(kids => \@sets);
$find_mods->($seq, \@layers, \@other_mods);
my $w = $tikz->width;
my $canvas = '';
if (defined $w and defined $h) {
require LaTeX::TikZ::Set::Rectangle;
- $seq->clip(LaTeX::TikZ::Set::Rectangle->new(
- from => 0,
- width => $w,
- height => $h,
- ));
+ for (@sets) {
+ $_->clip(LaTeX::TikZ::Set::Rectangle->new(
+ from => 0,
+ width => $w,
+ height => $h,
+ ));
+ }
$_ = $tikz->len($_) for $w, $h;
$canvas = ",papersize={$w,$h},body={$w,$h}";
}
push @decls, LaTeX::TikZ::Mod::Layer->declare(@layers) if @layers;
push @decls, $_->declare($tikz) for @other_mods;
- my @content = (
+ my @bodies = map [
"\\begin{tikzpicture}",
- @{ $seq->draw($tikz) },
+ @{ $_->draw($tikz) },
"\\end{tikzpicture}",
- );
+ ], @sets;
- return \@header, \@decls, \@content;
+ return \@header, \@decls, @bodies;
}
sub len {
};
is $@, '', 'creating another colored raw set doesn\'t croak';
-check [ $foo, $baz ], 'mods folding 1', <<'RES';
+check Tikz->seq($foo, $baz), 'mods folding 1', <<'RES';
\begin{scope} [color=red]
\begin{scope} [line width=4.0pt]
\draw foo ;
\end{scope}
RES
-check [ $baz, $foo ], 'mods folding 2', <<'RES';
+check Tikz->seq($baz, $foo), 'mods folding 2', <<'RES';
\begin{scope} [color=red]
\draw baz ;
\begin{scope} [line width=4.0pt]
};
is $@, '', 'creating another raw set with modded width doesn\'t croak';
-check [ $foo, $baz, $qux ], 'mods folding 3', <<'RES';
+check Tikz->seq($foo, $baz, $qux), 'mods folding 3', <<'RES';
\begin{scope} [color=red]
\begin{scope} [line width=4.0pt]
\draw foo ;
\draw [line width=4.0pt] qux ;
RES
-check [ $foo, $qux, $baz ], 'mods folding 4', <<'RES';
+check Tikz->seq($foo, $qux, $baz), 'mods folding 4', <<'RES';
\begin{scope} [line width=4.0pt]
\begin{scope} [color=red]
\draw foo ;
\draw [color=red] baz ;
RES
-check [ $baz, $foo, $qux ], 'mods folding 5', <<'RES';
+check Tikz->seq($baz, $foo, $qux), 'mods folding 5', <<'RES';
\begin{scope} [color=red]
\draw baz ;
\begin{scope} [line width=4.0pt]
\draw [line width=4.0pt] qux ;
RES
-check [ $baz, $qux, $foo ], 'mods folding 6', <<'RES';
+check Tikz->seq($baz, $qux, $foo), 'mods folding 6', <<'RES';
\draw [color=red] baz ;
\draw [line width=4.0pt] qux ;
\begin{scope} [color=red,line width=4.0pt]
\end{scope}
RES
-check [ $qux, $foo, $baz ], 'mods folding 7', <<'RES';
+check Tikz->seq($qux, $foo, $baz), 'mods folding 7', <<'RES';
\begin{scope} [line width=4.0pt]
\draw qux ;
\begin{scope} [color=red]
\draw [color=red] baz ;
RES
-check [ $qux, $baz, $foo ], 'mods folding 8', <<'RES';
+check Tikz->seq($qux, $baz, $foo), 'mods folding 8', <<'RES';
\draw [line width=4.0pt] qux ;
\draw [color=red] baz ;
\begin{scope} [color=red,line width=4.0pt]