~tex-sx/tex-sx/development

« back to all changes in this revision

Viewing changes to spath_doc.tex

  • Committer: Andrew Stacey (Thargelion)
  • Date: 2011-10-18 18:18:43 UTC
  • Revision ID: stacey@math.ntnu.no-20111018181843-xoxrwfmpcz5q2gst
More tweaks on labels; added ability to configure crossing path

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 
73
73
\begin{example}
74
74
\begin{tikzpicture}
 
75
\useasboundingbox (-1,1) rectangle (2,-2);
75
76
\path[save path=\tmppath] (-1,0) -- (0,0) .. controls +(1,0) and +(1,0) .. (1,1);
76
77
\pgfoonew \mypath=new spath(\tmppath)
77
78
\mypath.prepare()
233
234
If not, the current path is modified.
234
235
 
235
236
\item \Verb+prepare()+
 
237
 
 
238
This fills out all the attributes.
 
239
Finding the information for an attribute involves ``walking'' along the path.
 
240
Therefore, if we're going to need more than one, it makes sense to do them all in one go.
 
241
Calling this method ensures that they are all filled in and does so more efficiently than calling each individually.
 
242
 
236
243
\item \Verb+at least three()+
 
244
 
 
245
One of the things that the \texttt{calligraphy} package wants to be able to do is taper a path.
 
246
To do this nicely, the path should have at least three drawing pieces.
 
247
This ensures that this is so by splitting it if it does not.
 
248
If it has one piece, it is split into three at the .3 and .7 marks.
 
249
If it has two pieces, each is split in half.
 
250
 
237
251
\item \Verb+taper out()+
 
252
 
 
253
This is used to taper a path.
 
254
In fact, it replaces the first drawing component by a simularted tapered path (actually the outline of the tapered path is returned).
 
255
The rest of the path is thrown away, so this should be used after the path has been split.
 
256
 
238
257
\item \Verb+split path by length(#1,#2,#3)+
 
258
 
 
259
This splits a path according to the length.
 
260
The first argument will be an \Verb+spath+ object corresponding to the first part of the path, the second the rest, and the third says how many tokens should be in the first part of the path.
 
261
Both pieces are ``proper'' paths, so the second will be given an initial \Verb+moveto+.
 
262
 
239
263
\item \Verb+split path by real length(#1,#2,#3)+
 
264
 
 
265
This is the same as \Verb+split path by length+ except that it uses the \Verb+real length+ as the criterion of when to split.
 
266
 
240
267
\item \Verb+split path by component(#1,#2,#3)+
 
268
 
 
269
This is the same as \Verb+split path by length+ except that it uses the \Verb+number of components+ as the criterion of when to split.
 
270
 
241
271
\item \Verb+split(#1,#2,#3)+
 
272
 
 
273
This is the method that actually does the splitting.
 
274
It depends on certain macros being set which the previous three methods initialise.
 
275
It should therefore not be called directly.
 
276
Consider it a ``private'' method.
 
277
 
242
278
\item \Verb+reprocess path()+
 
279
 
 
280
This reprocesses the path.
 
281
Some TikZ/PGF settings have implications for how a path is constructed (such as the \Verb+rounded corners+ option).
 
282
If these have changed since the path was originally defined, it might be reasonable to redraw the path under the new conditions.
 
283
This does so.
 
284
 
243
285
\item \Verb+set as current path()+
 
286
 
 
287
This replaces the current path by the path stored in this object.
 
288
 
244
289
\item \Verb+get from current path()+
 
290
 
 
291
This replaces the path stored in this object by the current path.
 
292
 
245
293
\item \Verb+use path(#1)+
 
294
 
 
295
This uses the path.
 
296
The argument should be one of the PGF usage commands: \Verb+draw+, \Verb+fill+, \Verb+clip+, or \Verb+discard+.
 
297
 
246
298
\item \Verb+use path with tikz(#1)+
 
299
 
 
300
This uses the path but in a TikZian way.
 
301
The argument should be a list of TikZ styles to be set for the path.
 
302
Imagine this as \Verb+\path[<options>] <path>;+.
 
303
 
247
304
\item \Verb+concatenate(#1,#2)+
 
305
 
 
306
This concatenates the path in the current object with that from another.
 
307
If the first argument is given (which should be a macro), the result will a new \Verb+spath+ object stored in that macro.
 
308
If not, the object will be modified itself.
 
309
Since paths start with a \Verb+moveto+, the concatenation will not be a continuous path. 
 
310
 
248
311
\item \Verb+concatenate with lineto(#1,#2)+
 
312
 
 
313
This concatenates the path as \Verb+concatenate+ does, except that the \Verb+moveto+ in the middle is replaced by a \Verb+lineto+.
 
314
 
249
315
\item \Verb+weld(#1,#2)+
 
316
 
 
317
This welds two paths together.
 
318
Welding is like concatenation except that the second path is translated so that its starting point is the final point of the first path (and the \Verb+moveto+ is removed).
 
319
 
250
320
\item \Verb+close()+
 
321
 
 
322
This closes the path.
251
323
\end{itemize}
252
324
 
 
325
\subsection{The \texttt{spath component} Object}
 
326
 
 
327
An \Verb+spath component+ object is an element in an array of \Verb+spath+ objects.
 
328
Each element contains an \Verb+spath+ object and pointers to the previous and successive components.
253
329
 
254
330
\begin{itemize}
255
331
\item \Verb+path+
 
332
 
 
333
This is the \Verb+spath+ object of the current element.
 
334
 
256
335
\item \Verb+next component+
 
336
 
 
337
This is the next \Verb+spath component+ object (if non-empty).
 
338
 
257
339
\item \Verb+previous component+
 
340
 
 
341
This is the previous \Verb+spath component+ object (if non-empty).
258
342
\end{itemize}
259
343
 
 
344
The methods for \Verb+spath component+s are as follows.
 
345
 
260
346
\begin{itemize}
261
347
\item \Verb+spath component(#1)+
 
348
 
 
349
This is the initialiser method.
 
350
The argument should be the previous component in the array.
 
351
 
262
352
\item \Verb+value(#1)+
 
353
 
 
354
This method, and the following ones, are exactly as in the \Verb+spath+ object.
 
355
 
263
356
\item \Verb+set(#1,#2)+
264
357
\item \Verb+let(#1,#2)+
265
358
\item \Verb+get(#1,#2)+
266
359
\item \Verb+show(#1)+
267
360
\item \Verb+set path(#1)+
 
361
 
 
362
This sets the \Verb+spath+ attribute of this object.
 
363
 
268
364
\item \Verb+apply to paths(#1,#2)+
 
365
 
 
366
This applies a method to all of the \Verb+spath+ objects in the array, starting with the current path and proceding to the next component, and so on.
 
367
The first argument is the method name, the second is any argument that is to be passed to that method.
 
368
 
269
369
\item \Verb+apply to previous paths(#1,#2)+
 
370
 
 
371
This applies a method to all of the \Verb+spath+ objects in the array, starting with the current path and proceding to the previous component, and so on.
270
372
\end{itemize}
271
373
 
 
374
There is an additional command for use when creating an array of \Verb+spath component+s.
 
375
This is \Verb+\spathsplit+.
 
376
It takes two arguments.
 
377
The first is a macro that will become the first component of an array of \Verb+spath component+s.
 
378
The second is a macro containing a soft path.
 
379
The soft path will be split into pieces according to its components (that is, at the \Verb+moveto+s) and stored in the array.
 
380
At the moment, the last component is (temporarily) available at the end of the split as the \Verb+\spath@this@component+ macro.
 
381
 
 
382
 
272
383
\end{document}
 
 
b'\\ No newline at end of file'