From: Vincent Pit Date: Wed, 21 Jul 2010 13:21:55 +0000 (+0200) Subject: Test rectangle and circle clips covering X-Git-Tag: v0.01~27 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=7a0f854a2dc8c6cfacb11841271427df318f4e20;p=perl%2Fmodules%2FLaTeX-TikZ.git Test rectangle and circle clips covering --- diff --git a/t/22-clip.t b/t/22-clip.t index b3a1616..0b0ac32 100644 --- a/t/22-clip.t +++ b/t/22-clip.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2 + 2 * 10; +use Test::More tests => 8 + 2 * 16; use LaTeX::TikZ; @@ -179,3 +179,119 @@ check $seq2, 'mods folding with clips and layers', <<'RES'; \end{pgfonlayer} RES +my $a = Tikz->point; +my $b = Tikz->point(4, 2); +my $c = Tikz->point(1, 3); +my $d = Tikz->point(2, 1); + +my $r1 = Tikz->rectangle($a, $b); +my $r2 = Tikz->rectangle($c, $d); + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($r1) + )->clip($r2); +}; +is $@, '', 'two intersecting rectangle clips doesn\'t croak'; + +check $seq, 'two intersecting rectangle clips', <<'RES'; +\begin{scope} +\clip (1cm,3cm) rectangle (2cm,1cm) ; +\begin{scope} +\clip (0cm,0cm) rectangle (4cm,2cm) ; +\draw foo ; +\end{scope} +\end{scope} +RES + +$r2 = Tikz->rectangle($a, $d); # $r2 is a subset of $r1 + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($r1) + )->clip($r2); +}; +is $@, '', 'two overlapping rectangle clips 1 doesn\'t croak'; + +check $seq, 'two overlapping rectangle clips 1', <<'RES'; +\begin{scope} +\clip (0cm,0cm) rectangle (2cm,1cm) ; +\draw foo ; +\end{scope} +RES + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($r2) + )->clip($r1); +}; +is $@, '', 'two overlapping rectangle clips 2 doesn\'t croak'; + +check $seq, 'two overlapping rectangle clips 2', <<'RES'; +\begin{scope} +\clip (0cm,0cm) rectangle (4cm,2cm) ; +\begin{scope} +\clip (0cm,0cm) rectangle (2cm,1cm) ; +\draw foo ; +\end{scope} +\end{scope} +RES + +my $c1 = Tikz->circle($a, 2); +my $c2 = Tikz->circle($d, 3); + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($c1) + )->clip($c2); +}; +is $@, '', 'two intersecting circle clips doesn\'t croak'; + +check $seq, 'two intersecting circle clips', <<'RES'; +\begin{scope} +\clip (2cm,1cm) circle (3cm) ; +\begin{scope} +\clip (0cm,0cm) circle (2cm) ; +\draw foo ; +\end{scope} +\end{scope} +RES + +$c2 = Tikz->circle($a, 1); # $c2 is a subset of $c1 + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($c1) + )->clip($c2); +}; +is $@, '', 'two overlapping circle clips 1 doesn\'t croak'; + +check $seq, 'two overlapping circle clips 1', <<'RES'; +\begin{scope} +\clip (0cm,0cm) circle (1cm) ; +\draw foo ; +\end{scope} +RES + +$seq = eval { + Tikz->seq( + Tikz->raw("foo") + ->clip($c2) + )->clip($c1); +}; +is $@, '', 'two overlapping circle clips 2 doesn\'t croak'; + +check $seq, 'two overlapping circle clips 2', <<'RES'; +\begin{scope} +\clip (0cm,0cm) circle (2cm) ; +\begin{scope} +\clip (0cm,0cm) circle (1cm) ; +\draw foo ; +\end{scope} +\end{scope} +RES