diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex | 108 |
1 files changed, 93 insertions, 15 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex index c18b7a61766..06145514b4d 100644 --- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex +++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-pics.tex @@ -46,7 +46,13 @@ anywhere). We have now defined a |seagull| pic type and can use it as follows: \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); } } -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \fill [fill=blue!20] (1,1) -- (2,2) pic {seagull} @@ -126,7 +132,13 @@ braces: this option behaves exactly like the |node contents| option and, indeed, the two are interchangeable.) % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz { \path (0,0) pic [pic type = seagull] (1,0) pic {seagull}; @@ -143,7 +155,13 @@ braces: of the origin refers to the last position used on the path or to the specified |at|. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz { % different ways of placing pics \draw [help lines] (0,0) grid (3,2); \pic at (1,0) {seagull}; @@ -157,7 +175,13 @@ braces: using the |transform shape| option, which has the same effect as for nodes: The ``outer'' transformation gets applied to the node: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz [scale=2] { \pic at (0,0) {seagull}; \pic at (1,0) [transform shape] {seagull}; @@ -167,7 +191,13 @@ braces: When the \meta{options} contain transformation commands like |scale| or |rotate|, these transformations always apply to the pic: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz [rotate=30] { \pic at (0,0) {seagull}; \pic at (1,0) [rotate=90] {seagull}; @@ -177,7 +207,13 @@ braces: Just like nodes, pics can also be positioned implicitly and, somewhat unsurprisingly, the same rules concerning positioning and sloping apply: % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \draw (0,0) to [bend left] pic [near start] {seagull} @@ -276,7 +312,14 @@ braces: \draw (-3mm,-3mm) rectangle (3mm,3mm); } } -\begin{codeexample}[width=6cm] +\begin{codeexample}[ + width=6cm, + pre={\tikzset{ + my pic/.pic = { + \path [pic actions] (0,0) circle[radius=3mm]; + \draw (-3mm,-3mm) rectangle (3mm,3mm); + } +}}] \tikz \pic {my pic}; \space \tikz \pic [red] {my pic}; \space \tikz \pic [draw] {my pic}; \space @@ -297,7 +340,13 @@ braces: regard), then comes the path, and then come all nodes and pics that are in front of the path in the order they appeared. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \fill [fill=blue!20] (1,1) -- (2,2) pic [behind path] {seagull} @@ -330,7 +379,13 @@ braces: As for nodes, a pic specification may start with |foreach|. The effect and semantics are the same as for nodes. % -\begin{codeexample}[] +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] \tikz \pic foreach \x in {1,2,3} at (\x,0) {seagull}; \end{codeexample} @@ -341,9 +396,15 @@ braces: \begin{stylekey}{/tikz/every pic (initially \normalfont empty)} This style is installed at the beginning of every pic. % -\begin{codeexample}[] -\begin{tikzpicture}[every node/.style={draw}] - \draw (0,0) node {A} -- (1,1) node {B}; +\begin{codeexample}[ + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0); + }, +}}] +\begin{tikzpicture}[every pic/.style={scale=2,transform shape}] + \pic foreach \x in {1,2,3} at (\x,0) {seagull}; \end{tikzpicture} \end{codeexample} \end{stylekey} @@ -416,7 +477,20 @@ braces: Just as for nodes, you can use the attribute--colon syntax to add an animation to a pic: % -\begin{codeexample}[animation list={0.5,1,1.5,2}] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + pre={\tikzset{ + seagull/.pic={ + % Code for a "seagull". Do you see it?... + \coordinate (-left wing) at (-3mm,0); + \coordinate (-head) at (0,0); + \coordinate (-right wing) at (3mm,0); + % + \draw (-left wing) to [bend left] (0,0) (-head) to [bend left] (-right wing); + } +}}, +] \tikz { \pic :rotate={0s="0", 20s="90"} {seagull}; \pic at (1.5,1.5) {seagull}; @@ -425,7 +499,11 @@ braces: % Naturally, you can also use animations in the code of a picture: % -\begin{codeexample}[animation list={0.5,1,1.5,2},width=3cm] +\begin{codeexample}[ + preamble={\usetikzlibrary{animations}}, + animation list={0.5,1,1.5,2}, + width=3cm, +] \begin{tikzpicture} [flapping seagull/.pic={ \draw (0,0) :path={ 0s= {"{(180:3mm) to [bend left] (0,0) to [bend left] (0:3mm)}"=base}, @@ -483,7 +561,7 @@ This string is transformed into the following: As example of a pic type that takes these values into account is the |angle| pic type: % -\begin{codeexample}[] +\begin{codeexample}[preamble={\usetikzlibrary{angles,quotes}}] \tikz \draw (3,0) coordinate (A) -- (0,1) coordinate (B) -- (1,2) coordinate (C) |