Debian Codegraph @

texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex

raw
1 % Copyright 2018 by Till Tantau
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \ProvidesFileRCS{pgfcoreobjects.code.tex}
11
12
13 % Object reuse
14
15
16 % Define a pgf object for reuse. Such objects will be stored
17 % efficiently internally.
18 %
19 % #1 = name for later reuse
20 % #2 = lower left corner point of bounding box
21 % #3 = upper right left corner point of bounding box
22 % #4 = pure pgf code (nothing too fancy!)
23 %
24 % Description:
25 %
26 % Used to define reusable objects. The object must be composed of
27 % basic pgf graphic primitives. Nothing fancy can be used. The
28 % created object will be stored as an xform object in pdf or as a
29 % postscript procedure in postscript.
30 %
31 % Example:
32 %
33 % \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}}
34 % {\pgfpathqmoveto{0pt}{0pt}
35 % \pgfpathqmoveto{10pt}{0pt}
36 % \pgfpathqmoveto{10pt}{10pt}
37 % \pgfpathqmoveto{0pt}{10pt}
38 % \pgfpathclose
39 % \pgfusepath{stroke}}
40 %
41 % \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm}
42 % \pgfuseobject{myrect}
43 % \end{pgfpicture}
44
45 \def\pgfdefobject#1#2#3#4{%
46 \pgfinterruptpath%
47 \pgf@relevantforpicturesizefalse%
48 \pgfsys@defobject{#1}{#2}{#3}{#4}%
49 \endpgfinterruptpath%
50 \ignorespaces%
51 }
52
53
54 % Use an object that was previously defined using pgfdefobject
55 %
56 % #1 = name of previously defined object
57 %
58 % Example:
59 %
60 % \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}}
61 % {\pgfqmoveto{0}{0}
62 % \pgfqmoveto{10}{0}
63 % \pgfqmoveto{10}{10}
64 % \pgfqmoveto{0}{10}
65 % \pgfclosestroke}
66 %
67 % \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm}
68 % \pgfuseobject{myrect}
69 % \end{pgfpicture}
70
71 \def\pgfuseobject#1{\pgfsys@beginscope\pgfsys@useobject{#1}{}\pgfsys@endscope}
72
73
74 % Use an object that was previously defined using pgfdefobject, but
75 % magnify the object by the current x and y register values
76 %
77 % #1 = name of previously defined object
78 %
79 % Example:
80 %
81 % \pgfdefobject{myrect}{\pgfpoint{-1pt}{-1pt}}{\pgfpoint{11pt}{11pt}}
82 % {\pgfqmoveto{0}{0}
83 % \pgfqmoveto{10}{0}
84 % \pgfqmoveto{10}{10}
85 % \pgfqmoveto{0}{10}
86 % \pgfclosestroke}
87 %
88 % \begin{pgfpicture}{0cm}{0cm}{1cm}{1cm}
89 % \pgf@x=2pt% Scale by factor two in x-direction
90 % \pgf@y=2pt% Scale by factor two in y-direction
91 % \pgfuseobjectmagnify{myrect}
92 % \end{pgfpicture}
93
94 \def\pgfuseobjectmagnify#1{%
95 \pgfsys@beginscope%
96 \pgfsys@useobject{#1}{\pgfsys@transformxyscale{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}}%
97 \pgfsys@endscope%
98 }
99
100
101 \endinput