diff options
author | Karl Berry <karl@freefriends.org> | 2010-10-29 00:31:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-10-29 00:31:31 +0000 |
commit | 6bc1f5497cfb2f56d65c80a4c36ea3bad6dc046c (patch) | |
tree | f7751da75030fb1e06653eeb44e579fcee09c65f /Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex | |
parent | ed0c7c756e441b2d2ba3633da233fc24361ac0d3 (diff) |
pgf 2.10 (28oct10)
git-svn-id: svn://tug.org/texlive/trunk@20236 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex | 242 |
1 files changed, 121 insertions, 121 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex index 21ddb1f445c..ea145e8fb06 100644 --- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex +++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-base-decorations.tex @@ -15,7 +15,7 @@ The commands for creating decorations are defined in this module, so you need to load this module to use decorations. This module is automatically loaded by the different decoration - libraries. + libraries. \end{pgfmodule} @@ -24,7 +24,7 @@ Decorations are a general way of creating graphics by ``moving along'' a path and, while doing so, either drawing something or constructing a new path. This could be as simple as extending a path with a -``zigzagged'' line\ldots +``zigzagged'' line\ldots \begin{codeexample}[] \tikz \draw decorate[decoration=zigzag] {(0,0) -- (3,0)}; @@ -69,9 +69,9 @@ Decoration automata (and the closely related meta-decoration automata) are a general concept for creating graphics ``along paths.'' For straight lines, this idea was first proposed by Till Tantau in an earlier version of \pgfname, the idea to extend this to arbitrary path -was proposed and implemented by Mark Wibrow. Further versitility is +was proposed and implemented by Mark Wibrow. Further versatility is provided by ``meta-decorations''. These are automata that decorate a -path with decorations. +path with decorations. In the present subsection the different ideas underlying decoration automata are presented. @@ -81,12 +81,12 @@ automata are presented. \subsubsection{The Different Paths} In order to prevent confusion with different types of path, such -as those that are extended, those that are decorated and those that +as those that are extended, those that are decorated and those that are created, the following conventions will be used: \begin{itemize} -\item - The \emph{preexisting} path refers to the current path in existence +\item + The \emph{preexisting} path refers to the current path in existence before a decoration environment. (Possibly this path has been created by another decoration used earlier, but we will still call this path the preexisting path also in this case.) @@ -95,14 +95,14 @@ are created, the following conventions will be used: decoration automaton moves along. The input path may consist of many line and curve input segments (for example, a circle or an ellipse consists of four curves). It is specified inside the decoration - environment. + environment. \item - The \emph{output} path refers to the path that the decoration + The \emph{output} path refers to the path that the decoration creates. Depending on the decoration, this path may or may not be empty (a decoration can also choose to use side-effects instead of producing an output path). The input path is always consumed by the decoration automaton, that is, it is no longer available in any way - after the decoration automaton has finished. + after the decoration automaton has finished. \end{itemize} The effect of a decoration environment is the following: The input @@ -123,10 +123,10 @@ automaton progresses, the current path is constantly being extend by the output path. This means that first time e |\pgfusepath| command is used on a decoration, the preexisting path is part of the path this command operates on; in subsequent calls only the part of the output -path constructed since the last |\pgfusepath| command will be used. +path constructed since the last |\pgfusepath| command will be used. You can use this mechanism to stroke or fill different part of the -output path in different colors, line widths, fills and shades; all +output path in different colors, line widths, fills and shades; all within the same decoration. Alternatively, a decoration can choose to produce no output path at all: the |text| decoration simply typesets text along a path. @@ -135,20 +135,20 @@ text along a path. \subsubsection{Segments and States} The most common use a decoration is to ``repeat something along a -path'' (for example, the |zigzag| decoration +path'' (for example, the |zigzag| decoration repeats \tikz\draw decorate[decoration=zigzag] {(0,0)--(\pgfdecorationsegmentlength,0)}; along a path). However, it not necessarily the case that only one thing be repeated: a decoration can consist of different parts, or \emph{segments}, repeated in a -particular order. +particular order. -When you declare a decoration, you provide a description +When you declare a decoration, you provide a description of how their different segments will be rendered. The description of each segment should be given in a way as if the ``x-axis'' of the segment is the tangent to the path at a particular point, and that point is the origin of the segment. Thus, for example, the segment of the |zigzag| decoration might be -defined using the following code: +defined using the following code: \begin{codeexample}[code only] \pgfpathlineto{\pgfpoint{5pt}{5pt}} \pgfpathlineto{\pgfpoint{15pt}{-5pt}} @@ -171,7 +171,7 @@ The width of a segment can (and must) be specified explicitly. \pgfname\ will use this width to find out the start point of the next segment and the correct rotation. The width the you provide need not be the ``real'' width of the segment, which allows -decoration segments to overlap or to be spaced far apart. +decoration segments to overlap or to be spaced far apart. The |zigzag| decoration only has one segment that is repeated again and again. However, we might also like to have \emph{different} segments @@ -180,12 +180,12 @@ example, we might have special segments at the start and at the end. Decorations use a mechanism known in theoretical in computer science as \emph{finite state automata} to describe which segment is used at a -particular point. The idea is the following: For the first segment we +particular point. The idea is the following: For the first segment we start in a special \emph{state} called the \emph{initial state}. In this state, and also in all other state later, \pgfname\ first computes how much space is left on the input path. That is, \pgfname\ keeps -track of the distance to the end of the input path. Attached to each state -there is a set of rules of the following form: ``If the remaining +track of the distance to the end of the input path. Attached to each state +there is a set of rules of the following form: ``If the remaining distance on the input path is less than $x$, switch to state~$q$.'' \pgfname\ checks for each of these rules whether it applies and, if so, immediately switches to state~$q$. @@ -224,10 +224,10 @@ this command describes the decoration automaton. will ``travel along the path,'' each time being moved along by a certain distance. This will also work if the path is not a straight line. That is, it is permissible that the path curves are veers at a - sharp angle. It is also permissible that while travelling along the + sharp angle. It is also permissible that while traveling along the input path the current input segment ends and a new input segment starts. In this case, the remaining distance on the first input segment is subtracted - from the \meta{dimension} and then we travelled along the second + from the \meta{dimension} and then we traveled along the second input segment for the remaining distance. This input segment may also end early, in which case we travel along the next input segment, and so on. Note that it cannot happen that we travel past the end of the @@ -246,12 +246,12 @@ this command describes the decoration automaton. \begin{command}{\state\marg{name}\oarg{options}\marg{code}} This command declares a new state inside the current decoration automaton. The state is named \meta{name}. - + When the decoration automaton is in state \meta{name}, the following things happen: \begin{enumerate} \item - The \meta{options} are parsed. This may lead, see below, to a + The \meta{options} are parsed. This may lead, see below, to a state switch. When this happens, the following steps are not executed. The \meta{options} are executed one after the other in the given order. If an option causes a state switch, the switch @@ -261,11 +261,11 @@ this command describes the decoration automaton. The \meta{code} is executed in a \TeX-group with the current transformation matrix setup in such a way that the origin is on the input path at the current point (the point at the distance - travelled up to now) and the coordinate system is rotated in + traveled up to now) and the coordinate system is rotated in such a way that the positive $x$-axis points in the direction of the tangent to the input path at the current point, while the positive $y$-axis points to the left of this tangent. - + As described earlier, the \meta{code} can have two different effects: If it just contains path construction commands, the decoration will produce an output path, which is extends the @@ -300,7 +300,7 @@ this command describes the decoration automaton. output path for the first invocation and the different parts of the rest of the output path for the following invocation. Here is an example: - + \begin{codeexample}[] \pgfdeclaredecoration{stars}{initial}{ \state{initial}[width=15pt] @@ -316,7 +316,7 @@ this command describes the decoration automaton. } } \tikz\path[decorate, decoration=stars, star point ratio=2, star points=5, - inner sep=0, minimum size=rnd*10pt+2pt] + inner sep=0, minimum size=rnd*10pt+2pt] (0,0) .. controls (0,2) and (3,2) .. (3,0) .. controls (3,-3) and (0,0) .. (0,-3) .. controls (0,-5) and (3,-5) .. (3,-3); @@ -362,13 +362,13 @@ this command describes the decoration automaton. state switches occur, the \meta{code} is executed and the repetition counter is decreased. Then, there is once more a chance of a state change caused by any of the \meta{options}. If - no repetition occurs, the \meta{code} is executed + no repetition occurs, the \meta{code} is executed once more and the counter is decreased once more. When the counter reaches zero, the \meta{code} is executed once more, but, then, a different state is entered, as specified by the |next state| option. - Note, that the maximum number of times the state will be executed + Note, that the maximum number of times the state will be executed is $\meta{repetitions}+1$. \end{key} \begin{key}{/pgf/decoration automaton/next state=\meta{new state}} @@ -388,7 +388,7 @@ this command describes the decoration automaton. \begin{key}{/pgf/decoration automaton/auto end on length=\meta{dimension}} This key is just included for convenience, it does nothing that cannot be achieved using the previous options. The effect is the - following: If the remaingin input path's length is at most + following: If the remaining input path's length is at most \meta{dimension}, the decorated path is ended with a straight line to the end of the input path and, possibly, it is closed, namely if the input path ended with a closepath @@ -419,7 +419,7 @@ this command describes the decoration automaton. transformational \TeX-group of the current segment, so that these results of these computations are available in the next state. For this, the following two options are useful: - + \begin{key}{/pgf/decoration automaton/persistent precomputation=\meta{precode}} If the \meta{code} of state is executed, the \meta{precode} is executed first and it executed outside the \TeX-group of the @@ -432,40 +432,40 @@ this command describes the decoration automaton. \meta{postcode} is executed after (and also outside) the \TeX-group of the main \meta{code}. \end{key} - + There are a number of macros and dimensions which may be useful inside a decoration automaton. The following macros are available: - + \begin{command}{\pgfdecoratedpathlength} The length of the input path. If the input path consists of several input segments, this number is the sum of the lengths of the - input segments. + input segments. \end{command} - + \begin{command}{\pgfdecoratedinputsegmentlength} The length of the current input segment of the input path. ``Current input segment'' refers to the input segment on which the current point - lies. + lies. \end{command} \begin{command}{\pgfpointdecoratedpathlast} The final point of the input path. \end{command} - + \begin{command}{\pgfpointdecoratedinputsegmentlast} The final point of the current input segment of the input path. \end{command} \begin{command}{\pgfdecoratedangle} The angle of the tangent to the decorated path at the \emph{origin} - of the current segment. The transformation matrix applied at - the beginning of a state includes a rotation equivalent to + of the current segment. The transformation matrix applied at + the beginning of a state includes a rotation equivalent to this angle. \end{command} - The following \TeX\ dimension registers are also available inside the + The following \TeX\ dimension registers are also available inside the automaton: - + \begin{command}{\pgfdecoratedremainingdistance} The remaining distance on the input path. \end{command} @@ -473,25 +473,25 @@ this command describes the decoration automaton. \begin{command}{\pgfdecoratedcompleteddistance} The completed distance on the input path. \end{command} - + \begin{command}{\pgfdecoratedinputsegmentremainingdistance} The remaining distance on the current input segment of the input path. \end{command} - + \begin{command}{\pgfdecoratedinputsegmentcompleteddistance} The completed distance on the current input segment of the input path. \end{command} Further keys and macros are defined and used by the decoration libraries, see Section~\ref{section-library-decorations}. - + The following example shows how these options can be used: \begin{codeexample}[] \pgfdeclaredecoration{complicated example decoration}{initial} { \state{initial}[width=5pt,next state=up] { \pgfpathlineto{\pgfpoint{5pt}{0pt}} } - + \state{up}[width=5pt,next state=down] { \ifdim\pgfdecoratedremainingdistance>\pgfdecoratedcompleteddistance @@ -504,7 +504,7 @@ this command describes the decoration automaton. \pgfpathlineto{\pgfpoint{0pt}{\pgfdecoratedremainingdistance}} \pgfpathlineto{\pgfpoint{5pt}{\pgfdecoratedremainingdistance}} \pgfpathlineto{\pgfpoint{5pt}{0pt}} - \fi% + \fi% } \state{down}[width=5pt,next state=up] { @@ -518,7 +518,7 @@ this command describes the decoration automaton. \pgfpathlineto{\pgfpoint{0pt}{-\pgfdecoratedremainingdistance}} \pgfpathlineto{\pgfpoint{5pt}{-\pgfdecoratedremainingdistance}} \pgfpathlineto{\pgfpoint{5pt}{0pt}} - \fi% + \fi% } \state{final} { @@ -548,21 +548,21 @@ decorations. \subsection{Using Decorations} -Once a decoration has been declared, it can be used. +Once a decoration has been declared, it can be used. \begin{environment}{{pgfdecoration}\marg{decoration list}} The \meta{environment contents} should contain commands for creating an path. This path is the basis for the \emph{input paths} for the decorations in the \meta{decoration list}. In detail, the - following happens: + following happens: \begin{enumerate} \item The preexisting unused path is saved. - \item + \item The path commands specified in \meta{environment contents} are executed and this resulting path is saved. The path is then divided into different \emph{input paths} as follows: - The format for each item in \marg{decoration list} is + The format for each item in \marg{decoration list} is \begin{quote} \marg{decoration}\marg{length}\opt{\marg{before code}\marg{after code}} \end{quote} @@ -590,35 +590,35 @@ Once a decoration has been declared, it can be used. (and possibly using) the output paths. These output paths extend (unless they are used) the current path. \end{enumerate} - + Some important points should be noted regarding the use of this environment: - + \begin{itemize} \item - If \meta{environment contents} does not begin with - |\pgfpathmoveto|, he last known point on the preexisting path is + If \meta{environment contents} does not begin with + |\pgfpathmoveto|, he last known point on the preexisting path is assumed as the starting point. \item - All except the last of any sequence of consecutive move-to commands + All except the last of any sequence of consecutive move-to commands in \meta{environment contents} are discarded. \item - Any move-to commands at end of \meta{environment contents} are + Any move-to commands at end of \meta{environment contents} are ignored. \item - Any close-path commands on the input path are interpreted as + Any close-path commands on the input path are interpreted as straight lines. - Internally somthing a little more complicated is going on, - however, a closed path on the input path has no effect on the - output path, other than causing the automaton to travel in a - straight line towards the location of the last move-to command on + Internally something a little more complicated is going on, + however, a closed path on the input path has no effect on the + output path, other than causing the automaton to travel in a + straight line towards the location of the last move-to command on the input path. \item Although tangent computations for the input path work with the last point on the preexisting path, no automatic move-to - operations are issued for the output path. - If an output path commences with a line-to or curve-to when the - existing path is empty, an appropriate move-to command should be + operations are issued for the output path. + If an output path commences with a line-to or curve-to when the + existing path is empty, an appropriate move-to command should be inserted before the decoration commences. \item If a decoration uses its own path, the first time this happens the @@ -628,8 +628,8 @@ Once a decoration has been declared, it can be used. When the decoration automata ``work on'' their respective input paths, before the automaton starts, \meta{before code} is executed. After the decoration automaton has finished, \meta{after - code} is executed. - + code} is executed. + \begin{codeexample}[] \begin{tikzpicture}[decoration={segment length=5pt}] \draw [help lines] grid (3,2); @@ -674,9 +674,9 @@ Once a decoration has been declared, it can be used. Returns the point corresponding to the end of the current input path. \end{command} - This means that if decorations do not use their own path, it is - possible to do something with them and and continue from the - correct place. + This means that if decorations do not use their own path, it is + possible to do something with them and continue from the + correct place. \begin{codeexample}[] \begin{tikzpicture} @@ -708,7 +708,7 @@ Once a decoration has been declared, it can be used. \end{tikzpicture} \end{codeexample} - After the |{decoration}| environment has finished, the following + After the |{decoration}| environment has finished, the following macros are available: \begin{command}{\pgfdecorateexistingpath} @@ -727,7 +727,7 @@ Once a decoration has been declared, it can be used. \begin{command}{\pgfpointdecoratedpathlast} The final point of the input path. \end{command} - + \begin{command}{\pgfpointdecorationpathlast} The final point of the output path. \end{command} @@ -735,12 +735,12 @@ Once a decoration has been declared, it can be used. The following style is executed each time a decoration is used. You may use it to setup default options for decorations. \begin{stylekey}{/pgf/every decoration (initially \normalfont empty)} - This sytle is executed for every decoration. + This style is executed for every decoration. \end{stylekey} \end{environment} \begin{plainenvironment}{{pgfdecoration}\marg{name}} - The plain-\TeX{} version of the |{pgfdecorate}| environment. + The plain-\TeX{} version of the |{pgfdecorate}| environment. % TODOsp: `pgfdecorate' right or `pgfdecoration'? really no idea \end{plainenvironment} \begin{contextenvironment}{{pgfdecoration}\marg{name}} @@ -758,7 +758,7 @@ environment). \pgfdecorate{{name}{\pgfdecoratedpathlength} {\pgfdecoratebeforecode}{\pgfdecorateaftercode}} // the path commands. -\endpgfdecorate +\endpgfdecorate \end{codeexample} \end{command} @@ -766,21 +766,21 @@ environment). Decorate the preexisting path with the decoration \meta{name}. \end{command} -Both the above commands use the current definitons of the following +Both the above commands use the current definitions of the following macros: \begin{command}{\pgfdecoratebeforecode} Code executed as \meta{before code}, see the description of - |\pgfdecorate|. + |\pgfdecorate|. \end{command} \begin{command}{\pgfdecorateaftercode} Code executed as \meta{after code}, see the description of - |\pgfdecorate|. + |\pgfdecorate|. \end{command} It may sometimes be useful to add an additional transformation -for each segment of a decoration. The following command allows +for each segment of a decoration. The following command allows you to define such a ``last minute transformation.'' \begin{command}{\pgfsetdecorationsegmenttransformation\marg{code}} @@ -817,11 +817,11 @@ you to define such a ``last minute transformation.'' \label{section-base-meta-decorations} -A meta-decoration provides an alternative way to decorate a path with -mutiple decorations. It is, in essence, an automaton that decorates +A meta-decoration provides an alternative way to decorate a path with +multiple decorations. It is, in essence, an automaton that decorates an input path with decoration automatons. In general, however, the end -effect is still that a path is decorated with other paths, and the input -path should be thought of as being divided into sub-input-paths, each with +effect is still that a path is decorated with other paths, and the input +path should be thought of as being divided into sub-input-paths, each with their own decoration. Like ordinary decorations, before a meta-decoration can be used it must be declared. @@ -833,105 +833,105 @@ meta-decoration can be used it must be declared. \meta{states} argument contains a description of the meta-decoration automaton's states and the transitions between them. The \meta{initial state} is the state in which the automaton starts. - - The |\state| command is similar to the one found in + + The |\state| command is similar to the one found in decoration declarations, and takes the same form: - + \begin{command}{\state\marg{name}\oarg{options}\marg{code}} Declares the state \meta{name} inside the current meta-decoration automaton. Unlike decorations, states in meta-decorations are not executed within a group, which makes the persistent computation options superfluous. Consider using an initial state with |width=0pt| to do precalculations that could speed the execution - of the meta-decoration. - + of the meta-decoration. + The \meta{options} are executed with the key path set to - |/pgf/meta-decorations automaton/|, and the following keys are defined for - this path: - + |/pgf/meta-decorations automaton/|, and the following keys are defined for + this path: + \begin{key}{/pgf/meta-decoration automaton/switch if less than=\meta{dimension}| to |\meta{new state}} This causes \pgfname\ to check whether the remaining distance to the end of the input path is less than - \meta{dimension}, and, if so, to immediately switch to the state - \meta{new state}. When this key is evaluated, the macro - |\pgfmetadecoratedpathlength| will be defined as the total length of + \meta{dimension}, and, if so, to immediately switch to the state + \meta{new state}. When this key is evaluated, the macro + |\pgfmetadecoratedpathlength| will be defined as the total length of the decoration path, allowing for values such as |\pgfmetadecoratedpathlength/8|. \end{key} - + \begin{key}{/pgf/meta-decoration automaton/width=\meta{dimension}} As always, this option will cause an immediate switch to the state |final| if the remaining distance on the input path is less than - \meta{dimension}. + \meta{dimension}. Otherwise, this option tells \pgfname\ the width of the ``meta-segment'', that is, the length of the sub-input-path which the decoration automaton specified in \meta{code} will decorate. \end{key} - + \begin{key}{/pgf/meta-decoration automaton/next state=\meta{new state}} After the code for a state has been executed, a state switch to \meta{new state} is performed. If this option is not given, the next state is the same as the current state. \end{key} - - The code in \meta{code} is quite different from the code in a + + The code in \meta{code} is quite different from the code in a decoration state. In almost all cases only the following three - macros will be required: - + macros will be required: + \begin{command}{\decoration\marg{name}} This sets the decoration for the current state to \meta{name}. If this command is omitted, the |moveto| decoration will be used. \end{command} - + \begin{command}{\beforedecoration\marg{before code}} Defines \marg{before code} as (typically) \pgfname{} commands to be executed before the decoration is applied to the current segment. This command can be omitted. - If you wish to set up some decoration specific parameters + If you wish to set up some decoration specific parameters such as segment length, or segment amplitude, then they can be set in \meta{before code}. \end{command} - + \begin{command}{\afterdecoration\marg{after code}} - Defines \marg{after code} as commands to be executed afer the + Defines \marg{after code} as commands to be executed after the decoration has been applied to the current segment. This command can be omitted. \end{command} - - There are some macros that may be usedful when creating + + There are some macros that may be useful when creating meta-decorations (note that they are all macros): - + \begin{command}{\pgfpointmetadecoratedpathfirst} When the \meta{before code} is executed, this macro stores the first point on the current - sub-input-path. + sub-input-path. \end{command} \begin{command}{\pgfpointmetadecoratedpathlast} When the \meta{after code} is executed, this macro stores the last point on the current - sub-input-path. + sub-input-path. \end{command} - + \begin{command}{\pgfmetadecoratedpathlength} The entire length of the entire input path. - \end{command} - + \end{command} + \begin{command}{\pgfmetadecoratedcompleteddistance} The completed distance on the entire input path. \end{command} - + \begin{command}{\pgfmetadecoratedremainingdistance} The remaining distance on the entire input path. \end{command} - + \begin{command}{\pgfmetadecoratedinputsegmentcompleteddistance} The completed distance on the current input segment of the entire input path. \end{command} - + \begin{command}{\pgfmetadecoratedinputsegmentremainingdistance} The remaining distance on the current input segment of the entire input path. @@ -951,12 +951,12 @@ meta-decoration can be used it must be declared. } \state{arrow}[ switch if less than=\pgfmetadecorationsegmentlength to final, - width=\pgfmetadecorationsegmentlength/3, + width=\pgfmetadecorationsegmentlength/3, next state=zigzag] { \decoration{curveto} \beforedecoration - { + { \pgfmathparse{\pgfmetadecoratedcompleteddistance*\factor} \pgfsetcolor{red!\pgfmathresult!yellow} \pgfpathmoveto{\pgfpointmetadecoratedpathfirst} @@ -975,7 +975,7 @@ meta-decoration can be used it must be declared. \pgfsetarrowsend{to} \pgfusepath{stroke} } - } + } \state{move}[width=\pgfmetadecorationsegmentlength/2, next state=arrow]{} \state{final}{} } @@ -1001,7 +1001,7 @@ Using meta-decorations is ``simpler'' than using decorations, because you can only use one meta-decoration per path. \begin{environment}{{pgfmetadecoration}\marg{name}} - This environment decorates the input path described in + This environment decorates the input path described in \meta{environment contents}, with the meta-decoration \meta{name}. \end{environment} |