Debian Codegraph @

texmf-dist/doc/latex/tkz-base/TKZdoc-base-BB.tex

raw
1 \section{Controlling Bounding Box}
2 From the \tkzimp{PgfManual} :"When you add the clip option, the current path is used for clipping subsequent drawings. Clipping never enlarges the clipping area. Thus, when you clip against a certain path and then clip again against another path, you clip against the intersection of both.
3 The only way to enlarge the clipping path is to end the {pgfscope} in which the clipping was done. At the end of a {pgfscope} the clipping path that was in force at the beginning of the scope is reinstalled."
4
5
6 First of all, you don't have to deal with \TIKZ\ the size of the bounding box. Early versions of \tkzNamePack{tkz-euclide} did not control the size of the bounding box, now with \tkzNamePack{\tkznameofpack} 4 the size of the bounding box is limited.
7
8 The initial bounding box after using the macro \tkzcname{tkzInit} is defined by the rectangle based on the points $(0,0)$ and $(10,10)$. The \tkzcname{tkzInit} macro allows this initial bounding box to be modified using the arguments (\tkzname{xmin}, \tkzname{xmax}, \tkzname{ymin}, and \tkzname{ymax}). Of course any external trace modifies the bounding box. \TIKZ\ maintains that bounding box. It is possible to influence this behavior either directly with commands or options in \TIKZ\ such as a command like \tkzcname{useasboundingbox} or the option \tkzname{use as bounding box}. A possible consequence is to reserve a box for a figure but the figure may overflow the box and spread over the main text.
9 The following command \tkzcname{pgfresetboundingbox} clears a bounding box and establishes a new one.
10
11 \subsection{Utility of \tkzcname{tkzInit}}
12 However, it is sometimes necessary to control the size of what will be displayed.
13 To do this, you need to have prepared the bounding box you are going to work in, this is the role of the macro \tkzNameMacro{tkzInit}. For some drawings, it is interesting to fix the extreme values (xmin,xmax,ymin and ymax) and to "clip" the definition rectangle in order to control the size of the figure as well as possible.
14
15 The two macros that are useful for controlling the bounding box:
16 \begin{itemize}
17 \item \tkzcname{tkzInit}
18 \item \tkzcname{tkzClip}
19 \end{itemize}
20 \vspace{20pt}
21
22 To this, I added macros directly linked to the bounding box. You can now view it, backup it, restore it (see the section Bounding Box).
23
24 \subsection{\tkzcname{tkzInit}}
25
26 \begin{NewMacroBox}{tkzInit}{\oarg{local options}}\hypertarget{init}{}%
27 \begin{tabular}{lll}%
28 options & default & definition \\
29 \midrule
30 \TOline{xmin} {0} {minimum value of the abscissae in cm}
31 \TOline{xmax} {10} {maximum value of the abscissae in cm}
32 \TOline{xstep}{1} {difference between two graduations in $x$}
33 \TOline{ymin} {0} {minimum y-axis value in cm }
34 \TOline{ymax} {10} {maximum y-axis value in cm}
35 \TOline{ystep}{1} {difference between two graduations in $y$}
36 \bottomrule
37 \end{tabular}
38
39 \medskip
40
41 The role of \tkzcname{tkzInit} is to define a \textcolor{red}{orthogonal} coordinates system and a rectangular part of the plane in which you will place your drawings using Cartesian coordinates.
42 This macro allows you to define your working environment as with a calculator. With \tkzname{\tkznameofpack} 4 \tkzcname{xstep} and \tkzcname{ystep} are always 1. Logically it is no longer useful to use \tkzcname{tkzInit}, except for an action like "Clipping Out".
43 \end{NewMacroBox}
44
45
46 \subsection{\tkzcname{tkzClip}}
47
48 \subsection{tkzClip}
49 \begin{NewMacroBox}{tkzClip}{\oarg{local options}}
50 The role of this macro is to make invisible what is outside the rectangle defined by (xmin~;~ymin) and (xmax~;~ymax).
51
52 \medskip
53 \begin{tabular}{lll}
54 \hline
55 options & default & definition \\
56 \midrule
57 \TOline{space} {1} {added value on the right, left, bottom and top of the background}
58 \bottomrule
59 \end{tabular}
60
61 \medskip
62
63 The role of the \tkzname{space} option is to enlarge the visible part of the drawing. This part becomes the rectangle defined by (xmin-space~;~ymin-space) and (xmax+space~;~ymax+space). \tkzname{space} can be negative! The unit is cm and should not be specified.
64 \end{NewMacroBox}
65
66 The role of this macro is to "clip" the initial rectangle so that only the paths contained in this rectangle are drawn.
67
68 \begin{tkzexample}[latex=8cm,small]
69 \begin{tikzpicture}
70 \tkzInit[xmax=4, ymax=3]
71 \tkzDefPoints{-1/-1/A,5/2/B}
72 \tkzDrawX \tkzDrawY
73 \tkzGrid
74 \tkzClip
75 \tkzDrawSegment(A,B)
76 \end{tikzpicture}
77 \end{tkzexample}
78
79 It is possible to add a bit of space
80 \begin{tkzltxexample}[]
81 \tkzClip[space=1]
82 \end{tkzltxexample}
83
84 \subsection{\tkzcname{tkzClip} and the option \tkzname{space}}
85 This option allows you to add some space around the "clipped" rectangle.
86 \begin{tkzexample}[latex=8cm,small]
87 \begin{tikzpicture}
88 \tkzInit[xmax=4, ymax=3]
89 \tkzDefPoints{-1/-1/A,5/2/B}
90 \tkzDrawX \tkzDrawY
91 \tkzGrid
92 \tkzClip[space=1]
93 \tkzDrawSegment(A,B)
94 \end{tikzpicture}
95 \end{tkzexample}
96 The dimensions of the "clipped" rectangle are \tkzname{xmin-1}, \tkzname{ymin-1}, \tkzname{xmax+1} and \tkzname{ymax+1}.
97
98 %<--------------------------------------------------------------------------->
99 % tkzShowBB
100 %<--------------------------------------------------------------------------->
101 \subsection{tkzShowBB}
102 The simplest macro.
103 \begin{NewMacroBox}{tkzShowBB}{\oarg{local options}}%
104 This macro displays the bounding box. A rectangular frame surrounds the bounding box. This macro accepts \TIKZ\ options.
105 \end{NewMacroBox}
106
107 \subsubsection{Example with \tkzcname{tkzShowBB}}
108 \begin{tkzexample}[latex=8cm,small]
109 \begin{tikzpicture}[scale=.5]
110 \tkzInit[ymax=5,xmax=8]
111 \tkzGrid
112 \tkzDefPoint(3,0){A}
113 \begin{scope}
114 \tkzClipBB
115 \tkzDefCircle[R](A,5)
116 \tkzDrawCircle(A,tkzPointResult)
117 \tkzShowBB[line width = 4pt,fill=teal!10,opacity=.4]
118 \end{scope}
119 \tkzDefCircle[R](A,4)
120 \tkzDrawCircle(A,tkzPointResult)
121 \end{tikzpicture}
122 \end{tkzexample}
123 %<--------------------------------------------------------------------------->
124 % tkzClipBB
125 %<--------------------------------------------------------------------------->
126 \subsection{tkzClipBB}
127 \begin{NewMacroBox}{tkzClipBB}{}%
128 The idea is to limit future constructions to the current bounding box.
129 \end{NewMacroBox}
130
131 \subsubsection{Example with \tkzcname{tkzClipBB} and the bisectors}
132
133 \begin{tkzexample}[latex=6cm,small]
134 \begin{tikzpicture}
135 \tkzInit[xmin=-3,xmax=6, ymin=-1,ymax=6]
136 \tkzDefPoint(0,0){O}\tkzDefPoint(3,1){I}
137 \tkzDefPoint(1,4){J}
138 \tkzDefLine[bisector](I,O,J) \tkzGetPoint{i}
139 \tkzDefLine[bisector out](I,O,J) \tkzGetPoint{j}
140 \tkzDrawPoints(O,I,J,i,j)
141 \tkzClipBB
142 \tkzDrawLines[add = 1 and 2,color=red](O,I O,J)
143 \tkzDrawLines[add = 1 and 2,color=blue](O,i O,j)
144 \tkzShowBB
145 \end{tikzpicture}
146 \end{tkzexample}
147
148 \endinput