Debian Codegraph @

texmf-dist/doc/metapost/byrne/byrne-latex.tex

raw
1 \begin{filecontents}{byrne-latex.bib}
2 @book{Byrne1847,
3 author = {Byrne, Oliver},
4 publisher = {William Pickering},
5 title = {{The first six books of the elements of Euclid, in which coloured diagrams and symbols are used instead of letters for the greater ease of learners}},
6 year = 1847
7 }
8 @book{Tufte90,
9 author = {Tufte, Edward R.},
10 isbn = {978-0-9613921-1-6},
11 publisher = {Graphics Press},
12 title = {{Envisioning Information}},
13 year = 1990
14 }
15 @misc{Slyusarev2017,
16 author = {Slyusarev, Sergey},
17 title = {{MetaPost + TeX rendition of Oliver Byrne's "The first six books of the Elements of Euclid"}},
18 year = {2017},
19 howpublished = {\url{https://github.com/jemmybutton/byrne-euclid}}
20 }
21 @misc{Rougeux2018,
22 author = {Rougeux, Nicholas},
23 title = {{Byrne’s Euclid}},
24 year = {2018},
25 howpublished = {\url{https://www.c82.net/euclid/}}
26 }
27 @misc{Okabe2008,
28 author = {Okabe, Masataka and Ito, Kei},
29 title = {{Color Universal Design (CUD) How to make figures and presentations that are friendly to Colorblind people}},
30 year = {2008},
31 howpublished = {\url{https://jfly.uni-koeln.de/color/}}
32 }
33 \end{filecontents}
34
35 \documentclass{ltxdoc}
36 \usepackage{byrne}
37 \usepackage{ccicons,bxtexlogo,listings,hyperref}
38 \hypersetup{
39 colorlinks=true,
40 linkcolor=blue,
41 filecolor=blue,
42 citecolor = black,
43 urlcolor=cyan,
44 }
45
46 \lstset{
47 language=MetaPost,
48 alsolanguage=TeX,
49 numbers=none,
50 basicstyle=\ttfamily\scriptsize
51 }
52
53 \def\mpPre{textLabels := true;}
54
55 \author{Sergey Slyusarev}
56 \title{``Byrne'' v. 0.2.5 package for \METAPOST\ and \LaTeX}
57
58 \begin{document}
59 \maketitle
60
61 \begin{abstract}
62 This document describes ``Byrne'' package for \METAPOST\ and \LaTeX.
63 \end{abstract}
64
65 \begin{centering}
66
67 This document is distributed under CC-BY-SA 4.0 license
68
69 \ccbysa
70
71 \href{https://github.com/jemmybutton/byrne-latex}{https://github.com/jemmybutton/byrne-latex}
72
73 \end{centering}
74
75 \section{Introduction}
76 Oliver Byrne's \href{https://archive.org/details/firstsixbooksofe00byrn/}{1847 edition on the first six books of Euclid's ``Elements''}\cite{Byrne1847} is an interesting example of tight interplay between text and graphics in information visualization. The main feature of this book is that instead of relying on letter designations to describe lines, angles, etc., all the diagrams in it are colored and parts of these diagrams are directly incorporated into text.
77
78 Recently this work met somewhat of a renaissance and in the span of a couple of years at least three independent attempts were made at reviving Byrne's work. In early 2017 the first six books \href{https://github.com/jemmybutton/byrne-euclid/}{remade in \ConTeXt} were published on GitHub, and later migrated to \LaTeX \cite{Slyusarev2017}, in late 2018 an \href{https://www.c82.net/euclid/}{interactive web-version} was published by Nicholas Rougeux\cite{Rougeux2018} and in late 2019 a \href{https://www.kroneckerwallis.com/product/euclids-elements-completing-oliver-byrnes-work/}{printed version} of all Euclid's 15 books was published by Kronecker Wallis. All three are very different in terms of approach and goals.
79
80 This package is a \LaTeX\ (specifically \LuaLaTeX) version of the toolkit devised for the \TeX version of the book. It consists of two parts: \METAPOST\ code to describe and render geometric constructions and \LaTeX\ code to incorporate these constructions in text.
81
82 \section{Requirements}
83
84 This package works with \LuaLaTeX\ and requires \texttt{luamplib v2.23.0} or higher.
85 \section{Example}
86
87 \begin{minipage}{\textwidth}
88 \vskip 0.5\baselineskip
89 \defineNewPicture{
90 textLabels := true;
91 angleSize := 1cm;
92 pair A, B, C;
93 A := (0, 0);
94 B := (0, 2cm);
95 C := (3cm, 0);
96 byAngleDefine(C, B, A, byyellow, 0);
97 byAngleDefine(B, A, C, byblue, 0);
98 byAngleDefine(A, C, B, byred, 0);
99 draw byNamedAngleResized();
100 byLineDefine(A, B, byred, 0, 0);
101 byLineDefine(B, C, byblue, 0, 0);
102 byLineDefine(C, A, byyellow, 0, 0);
103 draw byNamedLineSeq(0)(AB,BC,CA);
104 draw byLabelsOnPolygon(A, B, C)(ALL_LABELS, 0);
105 }
106 ~\hfill\drawCurrentPicture\hfill~
107 \vskip \baselineskip
108
109 In
110 \drawFromCurrentPicture[middle][triangleABC]{
111 startAutoLabeling;
112 draw byNamedLineSeq(0)(AB,BC,CA);
113 stopAutoLabeling;
114 }
115 the angle \drawAngle{A}
116 is a right angle, therefore \triangleABC
117 is a right-angled triangle.
118 In it $\drawUnitLine{CB} > \drawUnitLine{AB}$
119 and $\drawUnitLine{BC} > \drawUnitLine{AC}$.
120 \end{minipage}
121
122 \vskip 2\baselineskip
123 The construction above is described like this:
124 \vskip 1.5\baselineskip
125
126 \begin{lstlisting}
127 \usepackage{byrne}
128 ...
129 \defineNewPicture{ % MetaPost code to describe the main diagram is placed inside
130 textLabels := true; % This turns text labels on
131 pair A, B, C;
132 A := (0, 0);
133 B := (0, 2cm);
134 C := (3cm, 0);
135 byAngleDefine(C, B, A, byyellow, 0); % This defines a yellow angle CBA
136 byAngleDefine(B, A, C, byblue, 0);
137 byAngleDefine(A, C, B, byred, 0);
138 draw byNamedAngleResized(); % Draws angles.
139 byLineDefine(A, B, byred, 0, 0); % This defines a red line AB.
140 byLineDefine(B, C, byblue, 0, 0);
141 byLineDefine(C, A, byyellow, 0, 0);
142 draw byNamedLineSeq(1)(AB,BC,CA); % Draws joint lines in sequence
143 draw byLabelsOnPolygon(A, B, C)(0, 0); % Draws text labels
144 }
145 \drawCurrentPicture % Draws the diagram
146
147 In
148 \drawFromCurrentPicture[middle][triangleABC]{
149 startAutoLabeling;
150 draw byNamedLineSeq(0)(AB,BC,CA);
151 stopAutoLabeling;
152 }
153 the angle \drawAngle{A} is a right angle, therefore \triangleABC\ is
154 a right-angled triangle. In it $\drawUnitLine{CB} > \drawUnitLine{AB}$
155 and $\drawUnitLine{BC} > \drawUnitLine{AC}$.
156 \end{lstlisting}
157
158 \vskip 1.5\baselineskip
159
160 Several things to note here.
161
162 In the \METAPOST\ part:
163 All points are ordinary \METAPOST\ pairs and can be defined and manipulated as such. Normally every part of the diagram is first defined (e.g. \texttt{byAngleDefine} or \texttt{byLineDefine}) and then is drawn (e.g. \texttt{draw byNamedAngleResized...} or \texttt{draw byNamedLineSeq...}). Also, although Byrne didn't use text labels in his book, they are implemented in this package \ref{textlabels}. Normally they are placed semi-manually in the main diagram (using functions like \texttt{byLabelsOnPolygon}) and mostly automatically in offspring pictures. By default they are turned off, and to turn them on \texttt{textLabels := true;} should be set.
164
165 In the \LaTeX\ part:
166 The most general way to reference main diagram is to use \cs{drawFromCurrentPicture}. It will process arbitrary \METAPOST\ code based on the main diagram's code and output an image. However, it would be too cumbersome to use this route every time, so a few shortcuts are in place. If you do need to process arbitrary code, you can give picture a name (in the example it's \texttt{triangleABC}). It will define a macro of the same name \cs{triangleABC} which will output the same image again. For most common cases there are special macros which don't require you to write any \METAPOST\ code. For instance \cs{drawAngle} and \cs{drawUnitLine} allow you to call angles and lines simply by name. The names don't have to match the initial definition exactly. For instance, the angle in the example can be called \texttt{A}, \texttt{BAC} or \texttt{CAB} interchangeably, or the same line segment can be called either \texttt{BC} or \texttt{CB}.
167
168 For more examples you can look at the source code of the \href{https://github.com/jemmybutton/byrne-euclid/}{\ConTeXt\ version of Byrne's book.} This package shares syntax with it and its code can be transferred to \LaTeX\ with minimal changes.
169
170 The following reference guide is not complete and will be updated in the future.
171
172 \section{\METAPOST\ part reference}
173
174 \subsection{Global variables and settings}
175
176 \subsubsection{Global variables}\label{Variables}
177
178 There are several variables which control the looks and behaviour.
179
180 \texttt{lineWidth}\label{lineWidth}~— the width for regular lines, set to \texttt{2pt} by default. Normally referenced as \texttt{0}.
181
182 \texttt{lineWidthThin}~— the width for thin lines, set to \texttt{1pt} by default. Normally referenced as \texttt{1}.
183
184 \texttt{lineWidthHair}~— the width for superthin lines, set to \texttt{1/2pt} by default. Normally referenced as \texttt{2}.
185
186 \texttt{pointMarkSize}\label{pointMarkSize}~— size of point marks, set to \texttt{4pt} by default.
187
188 \texttt{pointLinesSize}\label{pointLinesSize}~— size for line segments used to depict points, set to \texttt{1/2cm} by default.
189
190 \texttt{defaultScaleFactor}~— global default scale factor, set to \texttt{1} by default.
191
192 \texttt{angleSize}\label{angleSize}~— angle arc radius, set to \texttt{1cm} by default.
193
194 \texttt{angleScale}\label{angleScale}~— scale factor for angle arcs, set to \texttt{1} by default.
195
196 \texttt{globalRotation}~— angle to rotate the whole picture.
197
198 \texttt{markLength}~— size of marks on lines, set to \texttt{3lineWidth} by default.
199
200 \texttt{rayExtension}~— length for a ray depiction, set to \texttt{1/3cm} by default.
201
202 % magnitudeSize := 5/18cm;
203 % magnitudeScale := 1;
204 % magnitudeGap := 3/2lineWidth;
205
206 \texttt{textLabels}~— whether to render text labels, set to \texttt{false} by default.
207
208 %ghostLines := true;
209
210 \texttt{autoRightAngles}\label{autoRightAngles}~— whether to depict right angles using angles instead of arcs, set to \texttt{false} by default.
211
212 %omitDuplicateTextLabels := false;
213
214 \texttt{textLabelShift}~— how far away to put text labels from points, set to \texttt{lineWidth} by default.
215
216 \texttt{compensateLineLabels}~— a boolean to determine if inline images of line segments should be centered regardless of whether line labels are turned on or not, set to \texttt{true} by default.
217
218 \texttt{lineLabelsOnTop}~— a boolean to determine if inline images of line segments should have labels on top, if labels are turned on, set to \texttt{true} by default.
219
220 \texttt{angleClockwiseMode}~— a boolean to determine if compound angles should be constructed clockwise, set to \texttt{false} by default.
221
222 \texttt{angleModeFallback}~— a boolean to determine if compound angles should fallback to the opposite direction if current direction fails, set to \texttt{false} by default.
223
224 %autoLabelingMode := false;
225 %mainPictureMode := false;
226
227 %pathToString
228
229 \subsubsection{defineColor.ColorName(color)}\label{defineColor}
230
231 \defineNewPicture{
232 textLabels := false;
233 pair A, B, C;
234 A := dir(60);
235 B := (0, 0);
236 C := dir(0);
237 forsuffixes s=byblack,byred,byblue,byyellow,oiBlack,oiOrange,oiSkyBlue,oiGreen,oiYellow,oiBlue,oiVermillion,oiPurple:
238 byAngleDefine.s(A, B, C,s, 0);
239 endfor;
240 }
241 Defines a color. Colors can be defined as regular \METAPOST\ colors as well, this is just a shorthand version.
242
243 \texttt{ColorName}~— mandatory color name of \texttt{suffix type}.
244
245 \texttt{color}~— an actual calor, can be either of \texttt{color} type or of \texttt{cmykcolor} type.
246
247 Some colors are predefined. Colors similar to the ones Byrne used for his book are: \texttt{byblack}\drawAngle{byblack}, \texttt{byred}\drawAngle{byred}, \texttt{byblue}\drawAngle{byblue}, \texttt{byyellow}\drawAngle{byyellow}. One obvious issue of any color coding is whether the colors are discernible by colorblind people. Byrne's colors should be mostly fine, but there are only foru of them. In case more colors are necessary, eight colors from \href{https://jfly.uni-koeln.de/color/}{colorblind-friendly palette by Okabe and Ito} \cite{Okabe2008} are defined: \texttt{oiBlack}\drawAngle{oiBlack}, \texttt{oiOrange}\drawAngle{oiOrange}, \texttt{oiSkyBlue}\drawAngle{oiSkyBlue}, \texttt{oiGreen}\drawAngle{oiGreen}, \texttt{oiYellow}\drawAngle{oiYellow}, \texttt{oiBlue}\drawAngle{oiBlue}, \texttt{oiVermillion}\drawAngle{oiVermillion}, \texttt{oiPurple}\drawAngle{oiPurple}. Also text labels \ref{textlabels} are helpful as a secondary means of identification.
248
249 %\subsubsection{selectOutlineColor.ColorName}\label{selectOutlineColor}
250
251 % Selects an outline color for a color.
252
253 % \texttt{ColorName}~— mandatory color name of \texttt{suffix type}.
254
255 % ...
256
257 \subsubsection{startTempScale(tmpScale); ... \METAPOST\ code ... stopTempScale;}\label{startTempScale}
258
259 Used to temporarily set scale factor for a section of code;
260
261 \texttt{tmpScale}~— scale factor for a section of code.
262
263 \subsubsection{startTempAngleScale(tmpAngleScale); ... \METAPOST\ code ... stopTempAngleScale;}\label{startTempAngleScale}
264
265 Used to temporarily set angle scale factor for a section of code;
266
267 \texttt{tmpAngleScale}~— angle scale factor for a section of code.
268
269 \subsubsection{startGlobalRotation(rotationAngle); ... \METAPOST\ code ... stopGlobalRotation;}\label{startGlobalRotation}
270
271 Used to temporarily set global rotation for a section of code;
272
273 \texttt{rotationAngle}~— global rotation for a section of code.
274
275 \subsubsection{startAutoLabeling; ... \METAPOST\ code ... stopAutoLabeling}\label{startAutoLabeling}
276
277 Used to turn auto labeling for a section of code. Most of the drawing functions have auto labeling which is turned off by default. Sometimes it's handy to use it instead of labeling items by hand.
278
279 \subsubsection{startAngleOppositeMode; ... \METAPOST\ code ... stopAngleOppositeMode}\label{startAngleOppositeMode}
280
281 Used to temporarily switch the default direction for compound angles.
282
283 %startOffspringPictureMode
284 %stopOffspringPictureMode
285
286 %startMainPictureMode
287 %stopMainPictureMode
288
289 \subsection{Lines}
290
291 % byLineRender
292 % byReturnLineLength
293
294 \subsubsection{byLineDefine.LineName(A, B, color, dashed, thick)}\label{byLineDefine}
295
296 Defines a straight line. Does not return anything.
297
298 \texttt{LineName}~— optional line name of \texttt{suffix type}. If no name is provided, it is being constructed from point names, e.g. \texttt{AB}.
299
300 \texttt{A, B}~— point names, of \texttt{suffix} type (i.e., variable names should be provided).
301
302 \texttt{color}~— line color, of \texttt{color} type.
303
304 \texttt{dashed}~— is line dashed. \texttt{0} for solid line and \texttt{1} for dashed line.
305
306 \texttt{thick}~— is line thick. \texttt{0} for regular line and \texttt{1} for thin line \ref{lineWidth}.
307
308 \defineNewPicture{
309 pair A, B, C, D;
310 A := (0, 0);
311 B := (2cm, 0);
312 C := (3cm, 0);
313 D := (5cm, 0);
314 byLineDefine(A, B, byred, 0, 0);
315 byLineDefine(C, D, byblue, 1, 1);
316 }
317 For example, this line \drawUnitLine{AB} is defined as \texttt{byLineDefine(A, B, byred, 0, 0);} and this line \drawUnitLine{CD} is defined as \texttt{byLineDefine(C, D, byblue, 1, 1);}
318
319 % byLineStylize
320
321 \subsubsection{byLine.LineName(A, B, color, dashed, thick)}\label{byLine}
322
323 Defines and draws a straight line. Returns a \texttt{picture} of the line.
324
325 Arguments are the same as in \texttt{byLineDefine} \ref{byLineDefine}.
326
327 % byLineFull
328 % byLineWithName
329 % byNamedLineFull
330
331 \subsubsection{byNamedLine(LINES\_LIST)}\label{byNamedLine}
332
333 Draws lines. Returns a picture of the lines.
334
335 \texttt{LINES\_LIST}~— a comma-separated list of line names.
336
337 \subsubsection{byNamedLineSeq(lineShift)(LINES\_LIST)}\label{byNamedLineSeq}
338
339 \defineNewPicture[1]{
340 pair A, B, C;
341 A := dir(45) scaled 1/4cm;
342 B := (0, 0);
343 C := dir(0) scaled 1/4cm;
344 byLineDefine(A, B, byred, 0, 0);
345 byLineDefine(B,C, byyellow, 0, 0);
346 draw byNamedLineSeq(0)(BC,AB) scaled 2;
347 }
348
349 Draws lines joined in sequence. Line joints look like this:\drawCurrentPicture. Returns a picture of the lines.
350
351 \texttt{lineShift}~— how much the lines are shifted perpendicular lines' axis. \texttt{1} is for one regular line thickness to one side%
352 \drawFromCurrentPicture[bottom]{
353 draw byNamedLineSeq(1)(BC,AB) scaled 2;
354 draw (A--B--C) scaled 2 withpen pencircle scaled 1/2pt;
355 },
356 \texttt{-1} is for one regular line thickness to the other side%
357 \drawFromCurrentPicture[bottom]{
358 draw byNamedLineSeq(-1)(BC,AB) scaled 2;
359 draw (A--B--C) scaled 2 withpen pencircle scaled 1/2pt;
360 }.
361
362 \texttt{LINES\_LIST}~— a comma-separated list of line names.
363
364 \subsubsection{byNamedLineSeqByPoint(lineShift, isCyclic)(POINTS\_LIST)}\label{byNamedLineSeq}
365
366 Draws lines joined in sequence, just as \texttt{byNamedLineSeq}, but built using a list of points.
367
368 \texttt{lineShift}~— how much the lines are shifted perpendicular lines' axis. \texttt{1} is for one regular line thickness to one side%
369
370 \texttt{isCyclic}~— sould the sequence be closed, boolean. Another way to prevent closing of the sequence is to add \texttt{noPoint} as the last point%
371
372 \texttt{POINTS\_LIST}~— a comma-separated list of point names.
373
374 \subsubsection{byMarkLine(position, color)(LineName)}\label{byMarkLine}
375
376 \defineNewPicture[1]{
377 pair A, B;
378 A := (0, 0);
379 B := (1cm, 0);
380 byLineDefine(A, B, byblue, 0, 0);
381 }
382
383 Defines and draws a mark on a line.
384
385 \texttt{position}~— a position of the mark. \texttt{0} for one end of the line, \texttt{1} for the other end of the line.
386
387 \texttt{color}~— mark color, of \texttt{color} type.
388
389 \texttt{LineName}~— line name, of \texttt{suffix} type.
390
391 For example this line mark \drawFromCurrentPicture{
392 startAutoLabeling;
393 draw byNamedLine(AB);
394 draw byLabelLine(0)(AB);
395 draw byMarkLine(1/4, byred, AB);
396 stopAutoLabeling;
397 } is drawn with \texttt{draw byMarkLine(1/4, byred, AB);}.
398
399 \subsubsection{byNamedMarkLine(LineName)}
400
401 Draws a defined mark on the given line.
402
403 \texttt{LineName}~— line name, of \texttt{suffix} type.
404
405 %byFindLinePointedThere
406 %byConstructCompoundLine
407 %byExpandLines
408 %byNamedCompoundLine
409 %byNamedCompoundRay
410 %byNamedCompoundIndLine
411 %byNamedCompoundLineRender
412 %generateLineSynonyms
413
414 \subsection{Points}
415
416 \subsubsection{byPointLabelDefine(A, pointLabel)}\label{byPointLabelDefine}
417
418 Defines a point text label, returns nothing. By default point names are the same as the names of respective variables.
419
420 \texttt{A}~— a name of a point of \texttt{suffix} type (i.e., variable name should be provided).
421
422 \texttt{pointLabel}~— point label of \texttt{string} type.
423
424 \subsubsection{byPointLabelRemove(POINTS\_LIST)}\label{byPointLabelRemove}
425
426 Sets text labels of multiple points to blank. Useful if text labels are turned on, but you don't want labels on certain points.
427
428 \texttt{POINTS\_LIST}~— a comma-separated list of point names.
429
430 \subsubsection{byPointMarkDefine(PointName)(color, style)}\label{byPointMarkDefine}
431
432 \defineNewPicture{
433 textLabels := false;
434 pair A, B;
435 A := (0, 0);
436 B := (1cm, 0);
437 draw byPointMark(A, byblue, 0);
438 draw byPointMark(B, byred, 1);
439 }
440
441 Defines a point mark.
442
443 \texttt{color}~— mark color, of \texttt{color} type.
444
445 \texttt{style}~— \texttt{0} for solid circle \drawPointM{A}, \texttt{1} for white circle with outline \drawPointM{B}. Mark size is controlled by \texttt{pointMarkSize} \ref{pointMarkSize}.
446
447 %byPointXYZDefine
448 %byPointXYZEmpty
449 %byIsPointInSpace
450 %byPair
451 %byRotatePoints
452 %byPointMarkRender
453 %byNamedPointMark
454 %byPointMark
455 %byNamedPointLines
456
457 \subsection{Arcs and circles}
458
459 %byCirclePathGenerate
460 %byArcRender
461
462 \subsubsection{byArcDefineBE.ArcName(O, begin, end, radius, color, dashed, thick, shift, endType)}\label{byArcDefineBE}
463
464 Defines an arc based on its center, radius and two angles. Returns nothing.
465
466 \defineNewPicture[1]{
467 textLabels := false;
468 pair A, B;
469 A := (0, 0);
470 }
471
472 \texttt{ArcName}~— optional arc name of \texttt{suffix type}. If no name is provided, it is being constructed from center point name, e.g. \texttt{O}.
473
474 \texttt{O}~— the center of the circle an arc is from, of \texttt{suffix} type (i.e., variable name should be provided).
475
476 \texttt{begin, end}~— beginning and ending of the arc in eighths (in essence, \texttt{arctime} of \texttt{fullcircle}). \texttt{0} for 3 o'clock, \texttt{2} for 12 o'clock etc. For instance, this
477 \drawFromCurrentPicture{
478 draw byArcBE(A, 0, 3, 2/6cm, byblue, 0, 0, 1, 0);
479 }
480 is \texttt{0, 3} and this
481 \drawFromCurrentPicture{
482 draw byArcBE(A, 5, 7, 2/6cm, byblue, 0, 0, 1, 0);
483 }
484 is \texttt{5, 7}.
485
486 \texttt{radius}~— arc radius.
487
488 \texttt{color}~— arc color, of \texttt{color} type.
489
490 \texttt{dashed}~— is arc line dashed. \texttt{0} for solid line and \texttt{1} for dashed line.
491
492 \texttt{thick}~— is arc line thick. \texttt{0} for regular line and \texttt{1} for thin line \ref{lineWidth}.
493
494 \texttt{shift}~— how much arc line is shifted. \texttt{1} is for one regular line thickness outwards
495 \drawFromCurrentPicture{
496 draw byArcBE(A, 1/2, 7/2, 1/6cm, byyellow, 0, 0, 1, 0) scaled 2;
497 draw (subpath (1/2, 7/2) of (fullcircle scaled 4/6cm)) withpen pencircle scaled 1/2pt;
498 }, \texttt{-1} is for one regular line thickness inwards
499 \drawFromCurrentPicture{
500 draw byArcBE(A, 1/2, 7/2, 1/6cm, byyellow, 0, 0, -1, 0) scaled 2;
501 draw (subpath (1/2, 7/2) of (fullcircle scaled 4/6cm)) withpen pencircle scaled 1/2pt;
502 }.
503
504 \texttt{endType}~— type of arc line ends. \texttt{0} for ends cut by the radii
505 \drawFromCurrentPicture{
506 draw byArcBE(A, 1/2, 7/2, 1/6cm, byred, 0, 0, 0, 0) scaled 2;
507 }
508 and \texttt{1} for ends cut by the chord
509 \drawFromCurrentPicture{
510 draw byArcBE(A, 1/2, 7/2, 1/6cm, byred, 0, 0, 0, 1) scaled 2;
511 }.
512
513 \subsubsection{byArcBE.arcName(O, begin, end, radius, color, dashed, thick, shift, endType)}\label{byArcBE}
514
515 Defines and draws an arc based on its center, radius and two angles. Returns the picture of the arc.
516
517 Arguments are the same as in \texttt{byArcDefineBE} \ref{byArcDefineBE}.
518
519 \subsubsection{byArcDefine.ArcName(O, B, E, radius, color, dashed, thick, shift, endType)}\label{byArcDefine}
520
521 Defines an arc based on its center, radius and two points. Returns nothing.
522
523 Arguments are the same as in \texttt{byArcDefineBE} \ref{byArcDefineBE}, except for instead of angles in eights points are used.
524
525 \texttt{ArcName}~— optional arc name of \texttt{suffix type}. If no name is provided, it is being constructed from point names, e.g. \texttt{BOE}.
526
527 \texttt{B, E}~— points in the direction of the beginning and the ending of the arc respectively. Of \texttt{suffix} type (i.e., variable names should be provided).
528
529 \subsubsection{byArc.ArcName(O, B, E, radius, color, dashed, thick, shift, endType))}\label{byArc}
530
531 Arguments are the same as in \texttt{byArcDefine} \ref{byArcDefine}.
532
533 \subsubsection{byNamedArcExact(ARCS\_LIST)}\label{byNamedArcExact}
534 Draws a picture of arcs just as they were defined. Returns a picture of the arcs.
535
536 \texttt{ARCS\_LIST}~— a comma-separated list of arc names.
537
538 \subsubsection{byNamedArcSeq(arcShift)(ARCS\_LIST)}\label{byNamedArcSeq}
539
540 Draws arcs joined in sequence (only affects dash patterns). Returns a picture of the arcs.
541
542 \texttt{arcShift}~— how much the arcs are shifted outwards. \texttt{1} is for one regular line thickness outwards.
543
544 \texttt{ARCS\_LIST}~— a comma-separated list of arc names.
545
546 \subsubsection{byNamedArc(ARCS\_LIST)}\label{byNamedArc}
547 Draws a picture of arcs, except of it ignores \texttt{shift} and \texttt{endType}. Returns a picture of the arcs.
548
549 \texttt{ARCS\_LIST}~— a comma-separated list of arc names.
550
551 %byNamedArcLabel
552
553 \subsubsection{byCircleDefineFree.CircleName(o, radius, color, dashed, thick, shift)}\label{byCircleDefineFree}
554
555 Defines a circle based on its center and radius. Returns nothing.
556
557 \defineNewPicture[1]{
558 }
559
560 \texttt{CircleName}~— optional circle name of \texttt{suffix type}. If no name is provided, \texttt{aCircle} is used for a name.
561
562 \texttt{o}~— the center of the circle, of \texttt{pair} type.
563
564 \texttt{radius}~— circle radius.
565
566 \texttt{color}~— circle color, of \texttt{color} type.
567
568 \texttt{dashed}~— is circle line dashed. \texttt{0} for solid line and \texttt{1} for dashed line.
569
570 \texttt{thick}~— is circle line thick. \texttt{0} for regular line and \texttt{1} for thin line \ref{lineWidth}.
571
572 \texttt{shift}~— how much circle line is shifted. \texttt{1} is for one regular line thickness outwards
573 \drawFromCurrentPicture{
574 byCircleDefineFree((0,0), 1/8cm, byyellow, 0, 0, 1);
575 draw byNamedCircle(aCircle) scaled 2;
576 draw fullcircle scaled 1/2cm;
577 }, \texttt{-1} is for one regular line thickness inwards
578 \drawFromCurrentPicture{
579 byCircleDefineFree((0,0), 1/8cm, byyellow, 0, 0, -1);
580 draw byNamedCircle(aCircle) scaled 2;
581 draw fullcircle scaled 1/2cm;
582 }.
583
584 \subsubsection{byCircleDefineR.CircleName(O, radius, color, dashed, thick, shift)}\label{byCircleDefineR}
585
586 Defines a circle based on its center and radius. Returns nothing.
587
588 Arguments are the same as in \texttt{byCircleDefineFree} \ref{byCircleDefineFree}, except for the center is not defined directly by a \texttt{pair}.
589
590 \texttt{CircleName}~— optional circle name of \texttt{suffix type}. If no name is provided, it is being constructed from center name, e.g. \texttt{O}.
591
592 \texttt{O}~— the center of the circle. Of \texttt{suffix} type (i.e., variable name should be provided).
593
594 \subsubsection{byCircleR.CircleName(O, radius, color, dashed, thick, shift)}\label{byCircleR}
595
596 Defines and draws circle based on its center and radius. Returns a picture of that circle.
597
598 Arguments are the same as in \texttt{byCircleDefineR} \ref{byCircleDefineR}.
599
600 \subsubsection{byCircleDefine.CircleName(O, A, color, dashed, thick, shift)}\label{byCircleDefine}
601
602 Defines circle based on its center and a point. Returns nothing.
603
604 Arguments are the same as in \texttt{byCircleDefineR} \ref{byCircleDefineR}, except for instead of the radius, a point through which the circle is drawn is used.
605
606 \texttt{CircleName}~— optional circle name of \texttt{suffix type}. If no name is provided, it is being constructed from point names, e.g. \texttt{OA}.
607
608 \texttt{A}~— a point through which the circle is drawn. Of \texttt{suffix} type (i.e., variable name should be provided).
609
610 \subsubsection{byCircle.CircleName(O, A, color, dashed, thick, shift)}\label{byCircle}
611
612 Defines and draws circle based on its center and a point. Returns a picture of that circle.
613
614 Arguments are the same as in \texttt{byCircleDefine} \ref{byCircleDefine}.
615
616 \subsubsection{byCircleABC.CircleName(A, B, C, color, dashed, thick, shift)}\label{byCircleABC}
617
618 Arguments are the same as in \texttt{byCircleDefineR} \ref{byCircleDefineR}, except for instead of the center and the radius, three points through which the circle is drawn are used.
619
620 \texttt{CircleName}~— optional circle name of \texttt{suffix type}. If no name is provided, it is being constructed from point names, e.g. \texttt{ABC}.
621
622 \texttt{A, B, C}~— points through which the circle is drawn. Of \texttt{suffix} type (i.e., variable names should be provided).
623
624 %byFindCircleCenterABC
625 %byFindCircleCenterABCinSpace
626 %byReturnCircleCenter
627
628 \subsubsection{byNamedCircle(CIRCLES\_LIST)}\label{byNamedCircle}
629
630 Draws circles. Returns a picture of the circles.
631
632 \texttt{CIRCLES\_LIST}~— a comma-separated list of circle names.
633
634 \subsection{Arbitraty figures}
635
636 \subsubsection{byArbitraryFigureDefine.ArbitraryFigureName(figurePath, col\-or, dashed, thick)}\label{byArbitraryFigureDefine}
637
638 Defines an arbitrary figure (basically, any path). Returns nothing.
639
640 \texttt{ArbitraryFigureName}~— optional figure name of \texttt{suffix type}. If no name is provided, \texttt{anArbitraryFigure} is used for a name.
641
642 \texttt{figurePath}~— figure path, of \texttt{path} type.
643
644 \texttt{color}~— figure color, of \texttt{color} type.
645
646 \texttt{dashed}~— is figure line dashed. \texttt{0} for solid line and \texttt{1} for dashed line.
647
648 \texttt{thick}~— is figure line thick. \texttt{0} for regular line and \texttt{1} for thin line \ref{lineWidth}.
649
650 \subsubsection{byArbitraryFigure.ArbitraryFigureName(figurePath, color, dash\-ed, thick)}\label{byArbitraryFigure}
651
652 Defines an arbitrary figure. Returns nothing.
653
654 Arguments are the same as in \texttt{byArbitraryFigure} \ref{byArbitraryFigure}.
655
656 \subsubsection{byNamedArbitraryFigure(ARBITRARY\_FIGURES\_LIST)}\label{byNamedArbitraryFigure}
657
658 Draws arbitrary figures. Returns a picture of the figures.
659
660 \texttt{ARBITRARY\_FIGURES\_LIST}~— a comma-separated list of figure names.
661
662 %byArbitraryFigureRender
663 %byArbitraryCurveDefine
664 %byNamedArbitraryCurve
665 %byListToPath
666 %byArbitraryCurve
667
668 \subsection{Filled figures}
669
670 %byFilledCircleSegment
671 %byNamedFilledCircleSegment
672 %byFilledCircleSector
673 %byNamedFilledCircleSector
674
675 \subsubsection{byPolygonDefine.PolygonName(POINTS\_LIST)(Color)}\label{byPolygonDefine}
676
677 Defines a polygon based on its vertex points. Returns nothing.
678
679 \texttt{PolygonName}~— optional polygon name \texttt{suffix}.
680
681 \texttt{POINTS\_LIST}~— a comma-separated list of point names.
682
683 \texttt{Color}~— line color, of \texttt{suffix} type (i.e. a variable name should be provided).
684
685 %byPolygonPathFromList
686
687 \subsubsection{byPolygon.polygonName(POINTS\_LIST)(Color)}\label{byPolygon}
688
689 Defines and draws a polygon based on its vertex points. Returns a picture of the polygon.
690
691 Arguments are the same as in \texttt{byPolygonDefine} \ref{byPolygonDefine}.
692
693 %byPolygonName
694
695 \subsubsection{byNamedPolygon(POLYGONS\_LIST)}\label{byNamedPolygon}
696
697 Draws polygons. Returns a picture of the polygons.
698
699 \texttt{POLYGONS\_LIST}~— a comma-separated list of polygon names.
700
701 %byMergePolygons
702 %polygonCleanup
703
704 \subsection{Angles}
705
706 \subsubsection{byAngleDefine.AngleName(A, B, C, color, style)}\label{byAngleDefine}
707
708 \defineNewPicture{
709 textLabels := false;
710 pair A, B, C, A', B', C', A'', B'', C'';
711 A := dir(60);
712 B := (0, 0);
713 C := dir(0);
714 A' := A shifted (1cm, 0);
715 B' := B shifted (1cm, 0);
716 C' := C shifted (1cm, 0);
717 A'' := A shifted (2cm, 0);
718 B'' := B shifted (2cm, 0);
719 C'' := C shifted (2cm, 0);
720 byAngleDefine(A, B, C, byred, 0);
721 byAngleDefine(A', B', C', byred, 1);
722 byAngleDefine(A'', B'', C'', byred, 2);
723 }
724
725 Defines an angle based on three points. Returns nothing.
726
727 \texttt{AngleName}~— optional angle name \texttt{suffix}.
728
729 \texttt{A, B, C}~— angle points. Of \texttt{suffix} type (i.e., variable names should be provided).
730
731 \texttt{color}~— angle color, of \texttt{color} type.
732
733 \texttt{style}~— angle arc style. \texttt{0} for solid filled sector \drawAngle{B}, \texttt{1} for arc \drawAngle{B'}, \texttt{2} for dashed arc \drawAngle{B''}. Default arc radius is determined by \texttt{angleSize} \ref{angleSize}. It can be temporarily changed using \texttt{angleScale} \ref{angleScale}. You can also define custom angle styles \ref{AngleStyles}.
734
735 \subsubsection{byConsiderAngleRight(AngleName)}\label{byConsiderAngleRight}
736
737 \defineNewPicture{
738 textLabels := false;
739 pair A, B, C, A', B', C';
740 A := dir(60)*cm;
741 B := (0, 0);
742 C := dir(0)*cm;
743 A' := A shifted (2cm, 0);
744 B' := B shifted (2cm, 0);
745 C' := C shifted (2cm, 0);
746 byAngleDefine(A, B, C, byyellow, 0);
747 byAngleDefine(A', B', C', byyellow, 0);
748 byConsiderAngleRight(A'B'C');
749 }
750 Makes a defined angle look like an angle \drawAngle{A'B'C'} instead of a circle arc \drawAngle{ABC}, as right angles are often depicted. Useful if an angle is not actually right in the diagram, but is meant to be right or assumed to be right. To make all the right angles look like this automatically, you can set \texttt{autoRightAngles := true;}\ref{autoRightAngles}.
751
752 \texttt{AngleName}~— name of the angle.
753
754 %byConstructAngleArc
755 %byIsArcClockwise
756 %byFullCircleToPlane
757
758 \subsubsection{byAngle.AngleName(A, B, C, color, style)}\label{byAngle}
759
760 Defines and draws an angle based on three points. Returns a picture of the angle.
761
762 Arguments are the same as in \texttt{byAngleDefine} \ref{byAngleDefine}.
763
764 \subsubsection{byAngleDefineExtended.AngleName(A, B, C, color, style)(OPTIONAL\_COLORS\_LIST)}\label{byAngleDefineExtended}
765
766 Defines an angle based on three points. Returns nothing.
767
768 Arguments are the same as in \texttt{byAngleDefine} \ref{byAngleDefine}, except for using this function it's possible to define optional colors for an angle.
769
770 \texttt{OPTIONAL\_COLORS\_LIST}~— a comma-separated list of optional color names. See \ref{AngleStyles} for details.
771
772 \subsubsection{byAngleExtended.AngleName(A, B, C, color, style)(OPTION\-AL\_COLORS\_LIST)}\label{byAngleExtended}
773
774 Defines and draws an angle based on three points. Returns a picture of the angle.
775
776 Arguments are the same as in \texttt{byAngleDefineExtended} \ref{byAngleDefineExtended}.
777
778 \subsubsection{byNamedAngle(ANGLES\_LIST)}\label{byNamedAngle}
779
780 Draws angles. Returns a picture of the angles.
781
782 \texttt{ANGLES\_LIST}~— a comma-separated list of polygon names.
783
784 %byNamedSolidAngle
785 %byProcessAnglesList
786 %byAngleMWhite
787 %byAngleMSolid
788 %byAngleMLine
789 %byAngleMThinLine
790 %byAngleMDashedLine
791 %byNamedAngleSidesFull
792 %byNamedAngleDummySides
793 %byNamedAngleSides
794 %byNamedAngleWithDummySides
795 %byNamedAngleResized
796 %generateAngleSynonyms
797 %sortPointAnglesList
798 %bySplitStringIntoAngles
799 %byConstructCompoundAngle
800 %twoRightAngles
801 %rightAngle
802 %byDefineGenericRightAngles
803
804 \subsubsection{Angle styles}\label{AngleStyles}
805
806 It's possible to add custom angle styles. To do this, you first need to define a function, with a particular set of arguments and then include this function's name into a special list. As an example here's the function which describes a regular solid angle sector:
807
808 \begin{lstlisting}
809 vardef byAngleMSolid (expr angleArc, angleColor)(suffix AngleOptionalColors) =
810 save p;
811 path p;
812 p := angleArc scaled (angleScale*angleSize);
813 image(
814 fill ((0, 0)--p--cycle) withcolor angleColor;
815 )
816 enddef;
817 \end{lstlisting}
818
819 Note the argument \texttt{AngleOptionalColors}. It is not used for solid angles and is not defined with \texttt{byAngleDefine}, but several optional colors can be defined using \texttt{byAngleDefineExtended} \ref{byAngleDefineExtended} and can be accessed using \texttt{AngleOptionalColors[0]}, \texttt{AngleOptionalColors[1]} etc.
820
821 And here's how this angle style is included in the list:
822
823 \begin{lstlisting}
824 byAngleMacroName[0] := "byAngleMSolid";
825 \end{lstlisting}
826
827 Here \texttt{0} is the value of \texttt{sty} argument used in \texttt{byAngleDefine} \ref{byAngleDefine} and such to call this particular angle style.
828
829 As a more practical example, in Byrne's book, in a couple of places for some reason he chooses not to use ordinary arcs and sectors, but instead goes with unique angle designs. In order not to include these peculiarities into the main lib in the \ConTeXt\ version they were defined \textit{in situ}. Here's the definition from IV.III:
830
831 \defineNewPicture{
832 vardef byAngleMSectors (expr angleArc, angleColor)(suffix angleOptionalColors) =
833 save p;
834 path p[];
835 p1 := (subpath(0, arctime (1/3arclength(angleArc)) of angleArc)
836 of angleArc)
837 scaled (angleScale*angleSize);
838 p2 := (subpath(arctime (1/3arclength(angleArc))
839 of angleArc, arctime(2/3arclength(angleArc)) of angleArc) of angleArc)
840 scaled (angleScale*angleSize);
841 p3 := (subpath(arctime (2/3arclength(angleArc))
842 of angleArc, length(angleArc)) of angleArc)
843 scaled (angleScale*angleSize);
844 image(
845 fill ((0, 0)--p1--cycle) withcolor angleOptionalColors[0];
846 fill ((0, 0)--p2--cycle) withcolor angleColor;
847 fill ((0, 0)--p3--cycle) withcolor angleOptionalColors[1];
848 )
849 enddef;
850 byAngleMacroName[3] := "byAngleMSectors";
851 textLabels := false;
852 pair A, B, C;
853 A := dir(45) scaled 1/4cm;
854 B := (0, 0);
855 C := dir(0) scaled 1/4cm;
856 byAngleDefineExtended(A, B, C, byred, 3)(byblue, byyellow);
857 }
858
859 \begin{lstlisting}
860 vardef byAngleMSectors (expr angleArc, angleColor)(suffix angleOptionalColors) =
861 save p;
862 path p[];
863 p1 := (subpath(0, arctime (1/3arclength(angleArc)) of angleArc)
864 of angleArc)
865 scaled (angleScale*angleSize);
866 p2 := (subpath(arctime (1/3arclength(angleArc))
867 of angleArc, arctime(2/3arclength(angleArc)) of angleArc) of angleArc)
868 scaled (angleScale*angleSize);
869 p3 := (subpath(arctime (2/3arclength(angleArc))
870 of angleArc, length(angleArc)) of angleArc)
871 scaled (angleScale*angleSize);
872 image(
873 fill ((0, 0)--p1--cycle) withcolor angleOptionalColors[0];
874 fill ((0, 0)--p2--cycle) withcolor angleColor;
875 fill ((0, 0)--p3--cycle) withcolor angleOptionalColors[1];
876 )
877 enddef;
878 byAngleMacroName[3] := "byAngleMSectors";
879 \end{lstlisting}
880
881 This angle style employs two optional colors and can be called by setting \texttt{style} argument \ref{byAngleDefine} to \texttt{3}. This is what the result of \texttt{byAngleDefineExtended(A, B, C, byred, 3)(byblue, byyellow);} (\ref{byAngleDefineExtended}) looks like:\drawAngle{B}.
882 %https://archive.org/details/firstsixbooksofe00byrn/page/126/mode/2up
883
884 %\subsection{Arrows}
885
886 %commonArrowSettings
887 %byRotationArrowDefine
888 %byGenerateRotationArrowPath
889 %byNamedRotationArrow
890 %byFlatArrowDefine
891 %byNamedFlatArrow
892
893 %\subsection{Spheres}
894
895 %\subsection{Magnitudes}
896
897 %byMagnitudeSymbolDefine
898 %byNamedMagnitudeSymbol
899 %byMagnitudeDefine
900 %byNamedMagnitude
901
902 \subsection{Text labels}\label{textlabels}
903
904 There are no text labels in Byrne's book, but, as Edward Tufte points out in his 1990 book, adding small text labels can actually help speed recognition of geometric elements \cite{Tufte90}. It's not clear whether it's indeed the case for the reader, but at the very least text labels provide the author with the means of linking source code with the rendered pages. Several functions listed below allow for adding text labels very similar to the ones suggested by Tufte.
905
906 Text labels are turned off by default. As a result, simply adding code for text labels won't make them visible. They only appear when \texttt{textLabels := true;} is set in the beginning of a main picture or globally by defining \texttt{\textbackslash def\textbackslash\{...\} mpPre} \ref{defineNewPicture}. Text labels don't always have to be added manually, most elements can do auto labeling \ref{startAutoLabeling} which is intended to work with standalone angles, polygons, etc.
907
908 %\subsubsection{byTextLabel(labelType, text, point, angle, distance)}\label{byTextLabel}
909 %Draws a text label. Returns a picture of the label.
910
911 \subsubsection{byLabelPoint(A, labelAngle, distance)}\label{byLabelPoint}
912 Draws a text label for a point. Returns a picture of the label.
913
914 \texttt{A}~— the point to label, of \texttt{suffix} type (i.e., point name should be provided).
915
916 \texttt{labelAngle}~— angle at which the label should be drawn in degrees.
917
918 \texttt{distance}~— distance at which the label should be drawn in \texttt{textLabelShift} units.
919
920 \subsubsection{byLabelLine(distance)(LINES\_LIST)}\label{byLabelLine}
921
922 Draws text labels for lines. Returns a picture of the labels.
923
924 \texttt{distance}~— distance at which the labels should be drawn in \texttt{textLabelShift} units.
925
926 \texttt{LINES\_LIST}~— a comma-separated list of line names.
927
928 \subsubsection{byLabelPolygon(distance)(POLYGONS\_LIST)}\label{byLabelPolygon}
929
930 Draws text labels for polygons. Returns a picture of the labels.
931
932 \texttt{distance}~— distance at which the labels should be drawn in \texttt{textLabelShift} units.
933
934 \texttt{POLYGONS\_LIST}~— a comma-separated list of polygon names.
935
936 %byLabelCircle
937
938 \subsubsection{byLabelsOnCircle(POINTS\_LIST)(CircleName)}\label{byLabelsOnCircle}
939
940 Draws text labels for points on a circle. Returns a picture of the labels.
941
942 \texttt{POINTS\_LIST}~— a comma-separated list of point names.
943
944 \texttt{CircleName}~— circle name of \texttt{suffix type}.
945
946 \subsubsection{byLabelsOnPolygon(POINTS\_LIST)(style, shift)}\label{byLabelsOnPolygon}
947
948 Draws text labels for points on a polygon. Returns a picture of the labels.
949
950 \defineNewPicture{
951 pair A, B, C, D;
952 D := (0, 0);
953 C := (1cm, 0);
954 B := (2cm, 0);
955 A := (1/2cm, 1cm);
956 byPolygonDefine(D, C, A)(byred);
957 byPolygonDefine(C, B, A)(byyellow);
958 }
959
960 \texttt{POINTS\_LIST}~— a comma-separated list of point names.
961
962 \texttt{style}~— specifies which points to omit. \texttt{0} to draw labels for all listed points
963 \drawFromCurrentPicture{
964 draw byNamedPolygon(DCA,CBA);
965 draw byLabelsOnPolygon(A, B, C, D)(0, 0);
966 }, \texttt{1} to draw labels for all listed points, except for the ones at straight angles
967 \drawFromCurrentPicture{
968 draw byNamedPolygon(DCA,CBA);
969 draw byLabelsOnPolygon(A, B, C, D)(1, 0);
970 }, \texttt{2} omits first and last points
971 \drawFromCurrentPicture{
972 draw byNamedPolygon(DCA,CBA);
973 draw byLabelsOnPolygon(A, B, C, D)(2, 0);
974 }, \texttt{3} omits the first point
975 \drawFromCurrentPicture{
976 draw byNamedPolygon(DCA,CBA);
977 draw byLabelsOnPolygon(A, B, C, D)(3, 0);
978 }, \texttt{4} omits the last point
979 \drawFromCurrentPicture{
980 draw byNamedPolygon(DCA,CBA);
981 draw byLabelsOnPolygon(A, B, C, D)(4, 0);
982 }.
983
984 \texttt{shift}~— negative to move labels closer, positive to move labels farther.
985
986 \subsubsection{byLabelLineEnd(A, B)(distance)}\label{byLabelLineEnd}
987
988 Draws a text label for a line end. Returns a picture of the label.
989
990 \texttt{A, B}~— line ends, of \texttt{suffix} type (i.e., point name should be provided).
991
992 \texttt{distance}~— negative to move labels closer, positive to move labels farther.
993
994 %byLabelAngleCompensate
995
996 \section{\LaTeX\ part reference}
997
998 \subsection{General purpose}
999
1000 \sloppy
1001
1002 \subsubsection{\textbackslash defineNewPicture [offspringPicture\-Sca\-leFactor] [mainPicture\-Sca\-le\-Factor] \{\METAPOST\ code\}}\label{defineNewPicture}
1003
1004 \fussy
1005
1006 This macro is used to describe a main diagram.
1007
1008 \texttt{offspringPictureScaleFactor}~— how much smaller offspring pictures should be. \texttt{1/3} by default.
1009
1010 \texttt{mainPictureScaleFactor}~— scale factor for the main picture. \texttt{1} by default.
1011
1012 \texttt{\METAPOST\ code}~— actual \METAPOST\ code to describe the main picture. To have some snippets of code always executed before and after the code for the main picture (e.g. to turn on text labels by default with \texttt{textLabels := true;}), define \cs{mpPre} and \cs{mpPost} macros respectively in the preamble of your document, like this:
1013
1014 \begin{lstlisting}
1015 \def\mpPre{...some \METAPOST\ code...}
1016 \def\mpPost{...some \METAPOST\ code...}
1017 \end{lstlisting}
1018
1019 \subsubsection{\textbackslash defineNewPictureBasedOnOld [offspringPicture\-Sca\-leFactor] [main\-Picture\-Sca\-le\-Factor] \{\METAPOST\ code\}}\label{defineNewPictureBasedOnOld}
1020
1021 Works exacly like \ref{defineNewPicture}, but instead of creating a new instance, it uses the same instance as previously defined picture, retaining all its variables and definitions.
1022
1023 \subsubsection{\textbackslash drawCurrentPicture}
1024
1025 Draws the main diagram.
1026
1027 % \drawImageFromCurrentInstance
1028
1029 % \unmarkPictAsReady
1030
1031 % \addToUndefineList
1032
1033 \sloppy
1034
1035 \subsubsection{\textbackslash defineFromCurrentPicture \{verticalAlignment\} \{PictureName\} \{\METAPOST\ code\}}
1036
1037 \fussy
1038
1039 This macro is used to describe a diagram, based on the main diagram.
1040
1041 \texttt{verticalAlignment}~— vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1042
1043 \texttt{PictureName}~— picture name.
1044
1045 \texttt{MP code}~— actual \METAPOST\ code to describe the picture.
1046
1047 Can be drawn using \texttt{\textbackslash PictureName}.
1048
1049 \sloppy
1050
1051 \subsubsection{\textbackslash drawFromCurrentPicture [verticalAlignment] [PictureName] \{\METAPOST\nolinebreak\ code\}}
1052
1053 \fussy
1054
1055 This macro is used to describe and draw a diagram, based on the main diagram.
1056
1057 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1058
1059 \texttt{PictureName}~— optional picture name.
1060
1061 \texttt{\METAPOST\ code}~— actual \METAPOST\ code to describe the picture.
1062
1063 Can be drawn again later using \texttt{\textbackslash PictureName}.
1064
1065 % \drawDefinedPicture
1066
1067 \subsection{Specialized}
1068
1069 \subsubsection{\textbackslash drawUnitLine[LineSecondName]\{LineName\}}
1070
1071 Draws a line of unit length with colors and labels based on the line of the same name in the main diagram.
1072
1073 \texttt{LineSecondName}~— optional line name.
1074
1075 \texttt{LineName}~— name of the line to reference in the main diagram.
1076
1077 If a name is given, can be called later using \texttt{\textbackslash ulineLineNameLineSecondName}, otherwise~— \texttt{\textbackslash ulineLineName}.
1078
1079 \subsubsection{\textbackslash drawProportionalLine\{LineName\}}
1080
1081 Draws a line with colors and labels based on and length linearly proportional to the line of the same name in the main diagram.
1082
1083 \texttt{LineName}~— name of the line to reference in the main diagram.
1084
1085 Can be called later using \texttt{\textbackslash plineLineName}.
1086
1087 %\drawProportionalLine
1088
1089 \subsubsection{\textbackslash drawSizedLine[LineSecondName]\{LineName\}}
1090
1091 Draws a line with colors and labels based on and length proportional to the line of the same name in the main diagram.
1092
1093 \texttt{LineSecondName}~— optional line name.
1094
1095 \texttt{LineName}~— name of the line to reference in the main diagram.
1096
1097 If a name is given, can be called later using \texttt{\textbackslash slineLineNameLineSecondName}, otherwise~— \texttt{\textbackslash slineLineName}.
1098
1099 \subsubsection{\textbackslash drawUnitRay[RayName]\{LineName\}}
1100
1101 Draws a ray of unit length with colors and labels based on the line of the same name in the main diagram.
1102
1103 \texttt{RayName}~— optional ray name.
1104
1105 \texttt{LineName}~— name of the line to reference in the main diagram.
1106
1107 If a name is given, can be called later using \texttt{\textbackslash urayLineNameRayName}, otherwise~— \texttt{\textbackslash urayLineName}.
1108
1109 %\subsubsection{\textbackslash drawProportionalRay\{LineName\}}
1110
1111 % Draws a ray.
1112
1113 % \texttt{LineName}~— name of the line to reference in the main diagram.
1114
1115 % Can be called later using \texttt{\textbackslash prayAngleName}.
1116
1117 %\drawSizedRay
1118
1119 %\drawUnitIndLine
1120
1121 %\drawProportionalIndLine
1122
1123 \subsubsection{\textbackslash drawRightAngle, \textbackslash drawTwoRightAngles}
1124 \defineNewPicture{textLabels := false;}
1125 Draws a right angle \drawRightAngle\ and two right angles \drawTwoRightAngles\ respectively.
1126
1127 More broadly, following generic right angles are defined: \texttt{rightAngleNE} \drawAngle{rightAngleNE}, \texttt{rightAngleES} \drawAngle{rightAngleES}, \texttt{rightAngleSW} \drawAngle{rightAngleSW}, \texttt{rightAngleWN} \drawAngle{rightAngleWN}.
1128
1129 If you choose to go with angles instead of arcs for right angles (\ref{autoRightAngles}, \ref{byConsiderAngleRight}), adding \texttt{autoRightAngles := true;} to \texttt{\textbackslash mpPre} \ref{defineNewPicture} won't change the appearance of these angles, since they are defined before \texttt{\textbackslash mpPre} commands are executed. Instead, these angles should be redefined. There's a special command for this purpose: \texttt{byDefineGenericRightAngles(true);} where \texttt{true} tells this command to run \texttt{byConsiderAngleRight} \ref{byConsiderAngleRight} for each of the generic right angles.
1130
1131 \subsubsection{\textbackslash drawAngle\{AngleName\}}\label{drawAngle}
1132
1133 Draws an angle.
1134
1135 \defineNewPicture{
1136 pair A, B, C, D, E, O;
1137 O := (0, 0);
1138 A := (2cm, 0);
1139 B := A rotated (360/5);
1140 C := B rotated (360/5);
1141 D := C rotated (360/5);
1142 E := D rotated (360/5);
1143 byAngleDefine(A, O, B, byred, 0);
1144 byAngleDefine(B, O, C, byyellow, 0);
1145 byAngleDefine(C, O, D, byblue, 0);
1146 byAngleDefine(D, O, E, byblack, 0);
1147 byAngleDefine(E, O, A, byblack, 1);
1148 byLineDefine(A, O, byblack, 0, 0);
1149 }
1150
1151 \texttt{AngleName}~— name of the angle to reference in the main diagram.
1152 When just one letter is used, all the angles defined at this point will be drawn, e.g. \drawAngle{O}. When used to reference one single defined angle, the direction doesn't matter.
1153 E.g. \texttt{AOB} and \texttt{BOA} will return the same picture \drawAngle{AOB}.
1154 When used to reference an angle composed of several defined angles, the name sould be given counterclockwise.
1155 E.g. \texttt{\textbackslash drawAngle\{AOD\}} is \drawAngle{AOD} and \texttt{\textbackslash drawAngle\{DOA\}} is \drawAngle{DOA}.
1156
1157 Can be called later using \texttt{\textbackslash angleAngleName}.
1158
1159 \subsubsection{\textbackslash drawAngleWithSides \{AngleName\}}
1160
1161 \defineNewPicture{
1162 pair A, B, C, D;
1163 A := (1/2cm, 2cm);
1164 B := (0, 0);
1165 C := (3cm, 0);
1166 D := 1/2[A, C];
1167 byAngleDefine(A, B, D, byyellow, 1);
1168 byAngleDefine(D, B, C, byyellow, 0);
1169 byLineDefine(A, B, byred, 1, 0);
1170 byLineDefine(B, C, byblue, 0, 0);
1171 draw byNamedAngleResized();
1172 draw byNamedLineSeq(0)(AB, BC);
1173 }
1174
1175 Draws an angle and sections of its adjacent sides placed if angle portion style is not \texttt{0}. E.g., this angle \drawAngle{B} is drawn with \texttt{\textbackslash drawAngle\{B\}}, and this angle \drawAngleWithSides{B} is drawn with \texttt{\textbackslash drawAngleWithSides\{B\}}.
1176
1177 \texttt{AngleName}~— the same as in \ref{drawAngle}.
1178
1179 Can be called later using \texttt{\textbackslash anglewithsidesAngleName}.
1180
1181 \subsubsection{\textbackslash drawPolygon[verticalAlignment][PolygonNewName] \{Poly\-gon\-Na\-me\}}
1182
1183 Draws a polygon.
1184
1185 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1186
1187 \texttt{PolygonNewName}~— optional polygon name.
1188
1189 \texttt{PolygonName}~— name of the polygon to reference in the main diagram.
1190
1191 If a name is given, can be called later using \texttt{\textbackslash PolygonNewName}, otherwise~— \texttt{\textbackslash polygonPolygonName}.
1192
1193 \subsubsection{\textbackslash drawCircle[verticalAlignment][scaleFactor]\{CircleName\}}
1194
1195 Draws a circle.
1196
1197 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1198
1199 \texttt{scaleFactor}~— optional scale factor for the circle to replace the default offspring picture scale factor.
1200
1201 \texttt{CircleName}~— name of the circle to reference in the main diagram.
1202
1203 Can be called later using \texttt{\textbackslash circleCircleName}.
1204
1205 \subsubsection{\textbackslash drawArc[verticalAlignment][scaleFactor]\{ArcName\}}
1206
1207 Draws an arc.
1208
1209 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1210
1211 \texttt{scaleFactor}~— optional scale factor for the arc to replace the default offspring picture scale factor.
1212
1213 \texttt{ArcName}~— name of the arc to reference in the main diagram.
1214
1215 Can be called later using \texttt{\textbackslash arcCircleName}.
1216
1217 \subsubsection{\textbackslash drawLine[verticalAlignment][LineNewName]\{LineName\}}
1218
1219 Draws a line.
1220
1221 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1222
1223 \texttt{LineNewName}~— optional line name.
1224
1225 \texttt{LineName}~— name of the line to reference in the main diagram.
1226
1227 If a name is given, can be called later using \texttt{\textbackslash LineNewName}, otherwise~— \texttt{\textbackslash lineLineName}.
1228
1229 \subsubsection{\textbackslash drawLineByPoints[verticalAlignment][LineNewName]\{PointNames\}}
1230
1231 Draws a line, built, using a list of points.
1232
1233 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1234
1235 \texttt{LineNewName}~— optional line name.
1236
1237 \texttt{PointNames}~— names of the points, constituting the line.
1238
1239 If a name is given, can be called later using \texttt{\textbackslash LineNewName}, otherwise~— \texttt{\textbackslash lineLineName}.
1240
1241 \subsubsection{\textbackslash drawPointM\{PointName\}}
1242
1243 \defineNewPicture{
1244 pair A, B, C, D;
1245 A := (0, 0);
1246 B := dir(15)*cm;
1247 C := B rotated 120;
1248 D := C rotated 120;
1249 byLineDefine(A, B, byred, 0, 0);
1250 byLineDefine(A, C, byyellow, 0, 0);
1251 byLineDefine(A, D, byblue, 0, 0);
1252 draw byNamedLine(AD);
1253 draw byNamedLineSeq(0)(AB,AC);
1254 draw byPointMark(A, byblack, 1);
1255 }
1256
1257 Draws a point, depicted as a small circle \drawPointM{A}.
1258
1259 \texttt{PointName}~— name of the point to reference in the main diagram.
1260
1261 Can be called later using \texttt{\textbackslash pointmPointName}.
1262
1263 \subsubsection{\textbackslash drawPointL[verticalAlignment][LinesToOmit]\{PointName\}}\label{drawPointL}
1264
1265 Draws a point, depicted as line segments starting/ending in it \drawPointL{A}. Only the lines which were actually drawn, not just defined, are used. Line segments' length is controlled by \texttt{pointLinesSize} \ref{pointLinesSize}.
1266
1267 \texttt{verticalAlignment}~— optional vertical alignment declaration. \texttt{middle} to align the picture with the middle of the line, anything else for bottom alignment.
1268
1269 \texttt{LinesToOmit}~— a comma-separated list lines, segments of which not to draw.
1270
1271 \texttt{PointName}~— name of the point to reference in the main diagram.
1272
1273 If a list of lines to omit is given, can be called later using \texttt{\textbackslash pointl\-Point\-Name\-Minus\-Lines\-To\-Omit}, otherwise~— \texttt{\textbackslash pointlPointName}.
1274
1275 \subsubsection{\textbackslash drawPoint[verticalAlignment][LinesToOmit]\{PointName\}}
1276
1277 Draws a point, depicted as line segments starting/ending in it with a point mark if defined \drawPoint{A}. Only the lines which were actually drawn, not just defined, are used.
1278
1279 Arguments are the same as in \texttt{drawPointL} \ref{drawPointL}.
1280
1281 If a list of lines to omit is given, can be called later using \texttt{\textbackslash point\-Point\-Name\-Minus\-Lines\-To\-Omit}, otherwise~— \texttt{\textbackslash pointPointName}.
1282
1283 %\drawMagnitude
1284
1285 \bibliographystyle{plain}
1286 \bibliography{byrne-latex}
1287
1288 \end{document}