]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - samples/synopsis.pl
Fix synopsis
[perl/modules/LaTeX-TikZ.git] / samples / synopsis.pl
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use blib;
7
8 use LaTeX::TikZ;
9
10 # A couple of lines
11 my $hline = Tikz->line(-1 => 1);
12 my $vline = Tikz->line([ 0, -1 ] => [ 0, 1 ]);
13
14 # Paint them in red
15 $_->mod(Tikz->color('red')) for $hline, $vline;
16
17 # An octogon
18 use Math::Complex;
19 my $octo = Tikz->closed_polyline(
20  map Math::Complex->emake(1, ($_ * pi)/4), 0 .. 7
21 );
22
23 # Only keep a portion of it
24 $octo->clip(Tikz->rectangle(-0.5*(1+i), 2*(1+i)));
25
26 # Fill it with dots
27 $octo->mod(Tikz->pattern(class => 'Dots', space_width => 10));
28
29 # Create a formatter object
30 my $tikz = Tikz->formatter(scale => 5);
31
32 # Put those objects all together and print them
33 my $seq = Tikz->seq($octo, $hline, $vline);
34 my ($head, $decl, $body) = $tikz->render($seq);
35 my @lines = (
36  "\\documentclass[12pt]{article}",
37  @$head,
38  "\\begin{document}",
39  "\\pagestyle{empty}",
40  @$decl,
41  "\\begin{center}",
42  @$body,
43  "\\end{center}",
44  "\\end{document}",
45 );
46 print "$_\n" for @lines;