]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ.pm
Introduce LaTeX::TikZ::Mod::Scale
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ.pm
index 644e0fbe0e6e4f7288962501017f61e983396b64..69a55c81ef7517b432c84232c7eb222984444121 100644 (file)
@@ -53,20 +53,20 @@ It allows you to build structures representing geometrical figures, apply a wide
 
 =head1 CONCEPTS
 
 
 =head1 CONCEPTS
 
-Traditionally, in TikZ, there are two ways of grouping elements, or I<ops>, together :
+Traditionally, in TikZ, there are two ways of grouping paths together :
 
 =over 4
 
 =item *
 
 
 =over 4
 
 =item *
 
-either as a I<sequence>, where each element is drawn in its own line :
+either as a I<sequence>, where each path is drawn in its own line :
 
     \draw (0cm,0cm) -- (0cm,1cm) ;
     \draw (0cm,0cm) -- (1cm,0cm) ;
 
 =item *
 
 
     \draw (0cm,0cm) -- (0cm,1cm) ;
     \draw (0cm,0cm) -- (1cm,0cm) ;
 
 =item *
 
-or as a I<path>, where elements are all drawn as one line :
+or as an I<union>, where paths are all drawn as one line :
 
     \draw (0cm,0cm) -- (0cm,1cm) (0cm,0cm) -- (1cm,0cm) ;
 
 
     \draw (0cm,0cm) -- (0cm,1cm) (0cm,0cm) -- (1cm,0cm) ;
 
@@ -74,7 +74,7 @@ or as a I<path>, where elements are all drawn as one line :
 
 This distinction is important because there are some primitives that only apply to paths but not to sequences, and vice versa.
 
 
 This distinction is important because there are some primitives that only apply to paths but not to sequences, and vice versa.
 
-Figures are made of ops, path or sequence I<sets> assembled together in a tree.
+Figures are made of path or sequence I<sets> assembled together in a tree.
 
 I<Modifiers> can be applied onto any set to alter the way in which it is generated.
 The two TikZ concepts of I<clips> and I<layers> have been unified with the modifiers.
 
 I<Modifiers> can be applied onto any set to alter the way in which it is generated.
 The two TikZ concepts of I<clips> and I<layers> have been unified with the modifiers.
@@ -83,12 +83,12 @@ The two TikZ concepts of I<clips> and I<layers> have been unified with the modif
 
 =head2 Containers
 
 
 =head2 Containers
 
-=head3 C<< Tikz->path(@ops) >>
+=head3 C<< Tikz->union(@seq) >>
 
 
-Creates a L<LaTeX::TikZ::Set::Path> object out of the ops C<@ops>.
+Creates a L<LaTeX::TikZ::Set::Union> object out of the paths C<@kids>.
 
     # A path made of two circles
 
     # A path made of two circles
-    Tikz->path(
+    Tikz->union(
            Tikz->circle(0, 1),
            Tikz->circle(1, 1),
           )
            Tikz->circle(0, 1),
            Tikz->circle(1, 1),
           )
@@ -97,9 +97,26 @@ Creates a L<LaTeX::TikZ::Set::Path> object out of the ops C<@ops>.
            'even odd rule',
           );
 
            'even odd rule',
           );
 
+=head3 C<< Tikz->join($connector, @kids) >>
+
+Creates a L<LaTeX::TikZ::Set::Chain> object that joins the paths C<@kinds> with the given C<$connector> which can be, according to L<LaTeX::TikZ::Set::Chain/connector>, a string, an array reference or a code reference.
+
+    # A stair
+    Tikz->join('-|', map [ $_, $_ ], 0 .. 5);
+
+=head3 C<< Tikz->chain($kid0, $link0, $kid1, $link1, ... $kidn) >>
+
+Creates a L<LaTeX::TikZ::Set::Chain> object that chains C<$kid0> to C<$kid1> with the string C<$link0>, C<$kid1> to C<$kid2> with C<$link1>, and so on.
+
+    # An heart-like shape
+    Tikz->chain([ 0, 1 ]
+     => '.. controls (-1, 1.5)    and (-0.75, 0.25) ..' => [ 0, 0 ]
+     => '.. controls (0.75, 0.25) and (1, 1.5)      ..' => [ 0, 1 ]
+    );
+
 =head3 C<< Tikz->seq(@kids) >>
 
 =head3 C<< Tikz->seq(@kids) >>
 
-Creates a L<LaTeX::TikZ::Set::Sequence> object out of the sequences, paths or ops C<@kids>.
+Creates a L<LaTeX::TikZ::Set::Sequence> object out of the sequences or paths C<@kids>.
 
     my $bag = Tikz->seq($sequence, $path, $circle, $raw, $point);
 
 
     my $bag = Tikz->seq($sequence, $path, $circle, $raw, $point);
 
@@ -251,6 +268,13 @@ Layers can also be directly applied to sets with the C<< ->layer >> method.
                    ->mod(Tikz->pattern(class => 'Dots'))
                    ->layer('top');
 
                    ->mod(Tikz->pattern(class => 'Dots'))
                    ->layer('top');
 
+=head3 C<< Tikz->scale($factor) >>
+
+Creates a L<LaTeX::TikZ::Mod::Scale> object that scales the sets onto which it apply by the given C<$factor>.
+
+    my $circle_of_radius_2 = Tikz->circle(0 => 1)
+                                 ->mod(Tikz->scale(2));
+
 =head3 C<< Tikz->width($line_width) >>
 
 Creates a L<LaTeX::TikZ::Mod::Width> object that sets the line width to C<$line_width> when applied.
 =head3 C<< Tikz->width($line_width) >>
 
 Creates a L<LaTeX::TikZ::Mod::Width> object that sets the line width to C<$line_width> when applied.
@@ -260,7 +284,7 @@ Creates a L<LaTeX::TikZ::Mod::Width> object that sets the line width to C<$line_
 
 =head3 C<< Tikz->color($color) >>
 
 
 =head3 C<< Tikz->color($color) >>
 
-Creates a L<LaTeX::TikZ::Mod::Color>object that sets the line color to C<$color> (given in the C<xcolor> syntax).
+Creates a L<LaTeX::TikZ::Mod::Color> object that sets the line color to C<$color> (given in the C<xcolor> syntax).
 
     # Paint the previous $thick_arrow in red.
     $thick_arrow->mod(Tikz->color('red'));
 
     # Paint the previous $thick_arrow in red.
     $thick_arrow->mod(Tikz->color('red'));