1

Regarding PGF decorations, consider the two dimensions with the catchy names (p. 1001 of the TikZ & PGF manual for version 3.0.1a)

  • \pgfdecoratedinputsegmentremainingdistance ... The remaining distance on the current input segment of the input path.
  • \pgfdecoratedinputsegmentcompleteddistance ... The completed distance on the current input segment of the input path.

I don't understand

  1. what an input segment is?
  2. how PGF calculates the remaining (resp. completed) distance on the current input segment?

The answer to the first question is complicated by the fact that there are several similar concepts that can be described as input segments.

  1. An input segment is a part of the input path. Every path breaks down to zero or more parts. Generally speaking, a part starts with a moveto operation, and ends just before the next moveto operation or just before the next pgfuse operation, whichever comes first.
  2. An input segment is the subset of the path that corresponds to a single path extending operation:

    The input path may consist of many line and curve input segments (for example, a circle or an ellipse consists of four curves.) (bottom of p. 996)

  3. The input path is broken into segments by the decoration automaton as follows: when the automaton enters a new state, s, the next segment is that subset of the input path from the end, e, of the previous segment to the point, p, further along the input path, whose curvilinear distance from e is specified by s's width option.

Note that

  • A segment(1) can consist of several segments(2).
  • A segment(2) can consist of several segments(3).
  • A segment(3) can span several segments(1) as well as several segments(2).

The answer to the second question is complicated by the following facts:

  1. The decoration output path is not the same as the decoration input path.

  2. '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.' (p. 997)

1 Answer 1

3

When you write

\draw (0,0) -- (1,0) arc (20:230:1 and 2);

this translates into \pgfpathmoveto, \pgfpathlineto etc. primitives. Each of these denote an input segment. If there are nested decorations these also become sub primitives and each of them are segments of the path that are input by the user.

The path length is calculated by the soft path layer which I don't know how to summarize. Once the total length is known the state machine starts updating the decorated path and at each step decreases the remaining distance registers based on the last decorated point.

8
  • How many input segments are there in the example path you gave?
    – Evan Aad
    Jul 18, 2017 at 12:59
  • @EvanAad two segments
    – percusse
    Jul 18, 2017 at 13:31
  • Actually, there will be four input segments: 1 moveto, 1 lineto and 3 curveto segments. Arcs are constructed using a series of rotated "sub-arcs" each of a maximum of 90 degrees and approximated using cubic Bézier curves. Jul 18, 2017 at 14:14
  • @MarkWibrow If you want to go down that path :) But I think decoration state picks up the arc operation as one segment if you judge by the segmentlength register.
    – percusse
    Jul 18, 2017 at 14:27
  • @percusse: OK, thanks. So this answers my 1st question. What you're saying is that my 2nd definition of an input segment is the correct one. Now, regarding my 2nd question, is the following statement true: the values of the dimension parameters I mentioned in the beginning of my original post are up-to-date at the beginning of every state's code, but then remain fixed until the end of the state's code, regardless of what may go on inside the code.
    – Evan Aad
    Jul 18, 2017 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .