6 use Test::More tests => 5 + 4 * 5;
11 use LaTeX::TikZ::TestHelper;
13 using Tikz->formatter(
18 my ($set, $desc, $exp_decl, $exp) = @_;
20 local $Test::Builder::Level = $Test::Builder::Level + 1;
22 my ($head, $decl, $body) = check($set, $desc, $exp);
24 is $head->[-1], '\usetikzlibrary{patterns}', "$desc: header";
26 unless (ref $exp_decl eq 'ARRAY') {
27 $exp_decl = [ split /\n/, $exp_decl ];
30 is_deeply $decl, $exp_decl, "$desc: declarations";
35 ->mod(Tikz->pattern(class => 'Lines'));
37 is $@, '', 'creating a line pattern doesn\'t croak';
39 check_patterns $lines, 'a line pattern', <<'DECL', <<'BODY';
40 \pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
41 \pgfsetlinewidth{0.2pt}
42 \pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}}
43 \pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}}
47 \draw [fill,pattern=pata] foo ;
52 ->mod(Tikz->pattern(class => 'Dots'));
54 is $@, '', 'creating a dot pattern doesn\'t croak';
56 check_patterns $dots, 'a dot pattern', <<'DECL', <<'BODY';
57 \pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
58 \pgfpathcircle{\pgfqpoint{0.8pt}{0.8pt}}{0.2pt}
62 \draw [fill,pattern=patb] foo ;
65 my ($lines_mod) = $lines->mods;
66 my ($dots_mod) = $dots->mods;
74 is $@, '', 'creating a sequence with two identic patterns doesn\'t croak';
76 check_patterns $seq, 'a sequence with two identic patterns', <<'DECL', <<'BODY';
77 \pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
78 \pgfsetlinewidth{0.2pt}
79 \pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}}
80 \pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}}
84 \draw [fill,pattern=pata] foo ;
91 )->mod(Tikz->pattern(class => 'Lines', direction => 'vertical'));
94 'creating a sequence with two orthogonal line patterns doesn\'t croak';
96 check_patterns $seq, 'a sequence with two orthogonal line patterns',
98 \pgfdeclarepatternformonly{patc}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
99 \pgfsetlinewidth{0.2pt}
100 \pgfpathmoveto{\pgfqpoint{0.8pt}{-0.2pt}}
101 \pgfpathlineto{\pgfqpoint{0.8pt}{1.8pt}}
104 \pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
105 \pgfsetlinewidth{0.2pt}
106 \pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}}
107 \pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}}
111 \draw [fill,pattern=patc,pattern=pata] foo ;
120 is $@, '', 'creating a sequence with two different patterns doesn\'t croak';
122 check_patterns $seq, 'a sequence with two different patterns',
124 \pgfdeclarepatternformonly{patb}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
125 \pgfpathcircle{\pgfqpoint{0.8pt}{0.8pt}}{0.2pt}
128 \pgfdeclarepatternformonly{pata}{\pgfqpoint{-0.2pt}{-0.2pt}}{\pgfqpoint{1.8pt}{1.8pt}}{\pgfqpoint{1.6pt}{1.6pt}}{
129 \pgfsetlinewidth{0.2pt}
130 \pgfpathmoveto{\pgfqpoint{-0.2pt}{0.8pt}}
131 \pgfpathlineto{\pgfqpoint{1.8pt}{0.8pt}}
135 \draw [fill,pattern=patb,pattern=pata] foo ;