-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroadsigns.dtx
400 lines (400 loc) · 15.3 KB
/
roadsigns.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
% \iffalse meta-comment
%
% Copyright (C) 2023 by Logan Grosz <[email protected]>
% -------------------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<package>\ProvidesPackage{roadsigns}
%<package> [2023/05/14 v1.0 Graphics macros for drawing various roadsigns.]
%<package>\RequirePackage{tikz}
%<package>\usetikzlibrary{spath3,intersections}
%
%<*driver>
\ProvidesFile{roadsigns.dtx}
%</driver>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{roadsigns}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{roadsigns.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{162}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v1.0}{2023/05/14}{Initial version}
% \changes{v1.1}{2023/08/24}{Added parking symbol}
%
% \GetFileInfo{roadsigns.sty}
%
% \title{The \textsf{roadsigns} package\thanks{This document
% corresponds to \textsf{roadsigns}~\fileversion, dated \filedate.}}
% \author{Logan Grosz \\ \texttt{[email protected]}}
%
% \maketitle
%
% \section{Introduction}
%
% This package provides several graphics macros for drawing
% roadsign graphics. It doesn't do much more than that.
%
% \section{Usage}
%
% Use any of the described macros anywhere a
% \textsf{tikzpicutre} environment could normally be used.
%
% \DescribeMacro{\interstate\marg{text}}
% This macro draws the U.S. interstate shield with
% \meta{text} as the number. The image only supports 2
% digit wide interstate numbers. The ``I" should not be
% included in \meta{text}.
%
% \DescribeMacro{\highway\marg{text}}
% This macro draws the generic U.S. highway shield with
% \meta{text} as the number. This image only supports 2
% digit highway numbers.
%
% \DescribeMacro{\widehighway\marg{text}}
% This macro draws the generic wide U.S highway shield with
% \meta{text} as the number. This image only supports 3
% digit highway numbers.
%
% \DescribeMacro{\statehighway\marg{text}}
% This macro draws a generic state highway ``pill." This
% image supports both 2 and 3 digit highway numbers.
%
% \DescribeMacro{\parking}
% This macro draws a parking sign with a simple ``P".
%
% \StopEventually{\PrintChanges}
%
% \section{Implementation}
%
% \begin{macro}{\interstate}
% Four circles are draw and split by their intersections. The
% components from the resulting split are combined in such
% a way to create the U.S. interstate shield shape.
% \begin{macrocode}
\newcommand{\interstate}[1]{%
\begin{tikzpicture}[x=1em,y=1em]
\useasboundingbox (-0.8,-0.9) rectangle (0.8,0.8);
% \end{macrocode}
% The following paths are framing for the shield.
% \begin{macrocode}
\path[spath/save=circleBR] (0.2,0.1) circle (0.9);
\path[spath/save=circleBL] (-0.2,0.1) circle (0.9);
\path[spath/save=circleTR] (0.3,1.5) circle (0.9);
\path[spath/save=circleTL] (-0.3,1.5) circle (0.9);
\tikzset
{
% \end{macrocode}
% Only split the paths at the appropriate points
% \begin{macrocode}
spath/split at intersections={circleTR}{circleTL},
spath/split at intersections={circleTR}{circleBL},
spath/split at intersections={circleBR}{circleTL},
spath/split at intersections={circleBR}{circleBL},
% \end{macrocode}
% Save the components for later
% \begin{macrocode}
spath/get components of={circleTR}\cTR,
spath/get components of={circleBR}\cBR,
spath/get components of={circleTL}\cTL,
spath/get components of={circleBL}\cBL,
}
% \end{macrocode}
% Combines the appropriate components to make a shield
% shape
% \begin{macrocode}
\draw[
fill=white,
spath/use=\getComponentOf\cTR{4},
spath/use={\getComponentOf\cBL{5},reverse,weld},
spath/use={\getComponentOf\cBR{4},reverse,weld},
spath/use={\getComponentOf\cTL{3},weld},
spath/adjust and close=current,
];
\node at (0,0) {\sffamily#1};
\end{tikzpicture}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\highway}
% 8 circles and two bars connecting the two circles with
% the highest vertical position are creating and split at
% appropriate intersections. The components from the
% resutling splits are combined to create the generic U.S.
% highway shield. In order to split on tangent circles, a
% line which is normal to their tangent point is drawn and
% the circles are split with that line.
% \begin{macrocode}
\newcommand{\highway}[1]{%
\begin{tikzpicture}[x=1em,y=1em]
\useasboundingbox (-0.8,-0.8) rectangle (0.8,0.9);
% \end{macrocode}
% Draws circles and lines which frame the generic U.S.
% highway shield
% \begin{macrocode}
\path[spath/save=circle1R] (0.217,1.077) circle (0.390);
\path[spath/save=circle2R] (0.976,0.263) circle (0.40);
\path[spath/save=circle3R] (0.35,-0.15) circle (0.35);
\path[spath/save=circle4R] (0.35,-1.125) circle (0.625);
\path[spath/save=connectorR] (0.217,1.077) -- (0.976,0.263);
\path[spath/save=splitter1R] (0.976,0.263) -- (0.35,-0.15);
\path[spath/save=splitter2R] (0.35,-0.15) -- (0.35,-1.125);
\path[spath/save=circle1L] (-0.217,1.077) circle (0.390);
\path[spath/save=circle2L] (-0.976,0.263) circle (0.40);
\path[spath/save=circle3L] (-0.35,-0.15) circle (0.35);
\path[spath/save=circle4L] (-0.35,-1.125) circle (0.625);
\path[spath/save=connectorL] (-0.217,1.077) -- (-0.976,0.263);
\path[spath/save=splitter1L] (-0.976,0.263) -- (-0.35,-0.15);
\path[spath/save=splitter2L] (-0.35,-0.15) -- (-0.35,-1.125);
\tikzset
{
% \end{macrocode}
% Splits the paths at appropriate intersections.
% \begin{macrocode}
spath/split at intersections={circle1R}{circle1L},
spath/split at intersections={circle1R}{connectorR},
spath/split at intersections={circle1L}{connectorL},
spath/split at intersections={circle2R}{connectorR},
spath/split at intersections={circle2L}{connectorL},
spath/split at intersections={circle2R}{splitter1R},
spath/split at intersections={circle2L}{splitter1L},
spath/split at intersections={circle3R}{splitter1R},
spath/split at intersections={circle3L}{splitter1L},
spath/split at intersections={circle3R}{splitter2R},
spath/split at intersections={circle3L}{splitter2L},
spath/split at intersections={circle4R}{splitter2R},
spath/split at intersections={circle4L}{splitter2L},
spath/split at intersections={circle4R}{circle4L},
% \end{macrocode}
% Save the components for use later
% \begin{macrocode}
spath/get components of={circle1R}\cOneR,
spath/get components of={circle1L}\cOneL,
spath/get components of={connectorR}\cConnectorR,
spath/get components of={connectorL}\cConnectorL,
spath/get components of={circle2R}\cTwoR,
spath/get components of={circle2L}\cTwoL,
spath/get components of={circle3R}\cThreeR,
spath/get components of={circle3L}\cThreeL,
spath/get components of={circle4R}\cFourR,
spath/get components of={circle4L}\cFourL,
}
% \end{macrocode}
% Combines the appropriate components to make a shield
% shape.
% \begin{macrocode}
\draw[
fill=white,
spath/use={\getComponentOf\cOneR{3}},
spath/use={\getComponentOf\cConnectorR{2},weld},
spath/use={\getComponentOf\cTwoR{2},weld},
spath/use={\getComponentOf\cThreeR{3},reverse,weld},
spath/use={\getComponentOf\cFourR{2},weld},
spath/use={\getComponentOf\cFourL{4},weld},
spath/use={\getComponentOf\cThreeL{2},reverse,weld},
spath/use={\getComponentOf\cTwoL{3},weld},
spath/use={\getComponentOf\cConnectorL{2},reverse,weld},
spath/use={\getComponentOf\cOneL{3},weld},
spath/adjust and close=current,
];
\node at (0,0) {\sffamily#1};
\end{tikzpicture}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\widehighway}
% Similar to \textsf{\\highway}. The circles were brought
% further apart apart and another line which is tangent to
% the bottom four circles is used to elongate the bottom of
% the shield.
% \begin{macrocode}
\newcommand{\widehighway}[1]{%
\begin{tikzpicture}[x=1em,y=1em,scale=1.2]
\useasboundingbox (-1,-0.8) rectangle (1,0.8);
% \end{macrocode}
% These are the circles which make up the curves of the
% shield. One circle was used to looks about correct
% (circle3R). The rests' positions were calculated by
% drawing circles over a real image and converting vectors
% in one span to another.
% \begin{macrocode}
\path[spath/save=circle1R] (0.3,1.11511) circle (0.522311);
\path[spath/save=circle2R] (1.20532,0.190242) circle (0.38516);
\path[spath/save=circle3R] (0.55,-0.15) circle (0.35);
\path[spath/save=circle4R] (0.225,-0.794558) circle (0.294558);
\path[spath/save=circle1L] (-0.3,1.11511) circle (0.522311);
\path[spath/save=circle2L] (-1.20532,0.190242) circle (0.38516);
\path[spath/save=circle3L] (-0.55,-0.15) circle (0.35);
\path[spath/save=circle4L] (-0.225,-0.794558) circle (0.294558);
% \end{macrocode}
% These lines connect the top two circles with an arbitrary line which looks ``correct."
% \begin{macrocode}
\path[spath/save=conn12R] (0.440624,0.867885) -- (1.1101,0.210911);
\path[spath/save=conn12L] (-0.440624,0.867885) -- (-1.1101,0.210911);
% \end{macrocode}
% This path is a long line tangent to the bottom four circles.
% \begin{macrocode}
\path[spath/save=conn34] (0.7,-0.50) -- (-0.7,-0.50);
% \end{macrocode}
% These paths are used to split other paths which are not
% obviously intersecting, i.e. points where paths are
% tangent
% \begin{macrocode}
\path[spath/save=split23R] (1.20532,0.190242) -- (0.55,-0.15);
\path[spath/save=split23L] (-1.20532,0.190242) -- (-0.55,-0.15);
\path[spath/save=split3Conn34R] (0.55,-0.40) -- (0.55,-0.60);
\path[spath/save=split4Conn34R] (0.225,-0.40) -- (0.225,-0.60);
\path[spath/save=split3Conn34L] (-0.55,-0.40) -- (-0.55,-0.60);
\path[spath/save=split4Conn34L] (-0.225,-0.40) -- (-0.225,-0.60);
\tikzset
{
% \end{macrocode}
% Splits paths at appropriate intersections.
% \begin{macrocode}
spath/split at intersections={circle1R}{circle1L},
spath/split at intersections={circle1R}{conn12R},
spath/split at intersections={conn12R}{circle2R},
spath/split at intersections with={circle2R}{split23R},
spath/split at intersections with={circle3R}{split23R},
spath/split at intersections with={circle3R}{split3Conn34R},
spath/split at intersections with={conn34}{split3Conn34R},
spath/split at intersections with={conn34}{split4Conn34R},
spath/split at intersections with={circle4R}{split4Conn34R},
spath/split at intersections={circle4R}{circle4L},
spath/split at intersections={circle1L}{conn12L},
spath/split at intersections={conn12L}{circle2L},
spath/split at intersections with={circle2L}{split23L},
spath/split at intersections with={circle3L}{split23L},
spath/split at intersections with={circle3L}{split3Conn34L},
spath/split at intersections with={conn34}{split3Conn34L},
spath/split at intersections with={conn34}{split4Conn34L},
spath/split at intersections with={circle4L}{split4Conn34L},
% \end{macrocode}
% Saves the components for use later
% \begin{macrocode}
spath/get components of={circle1R}\circleOneR,
spath/get components of={circle2R}\circleTwoR,
spath/get components of={circle3R}\circleThreeR,
spath/get components of={circle4R}\circleFourR,
spath/get components of={circle1L}\circleOneL,
spath/get components of={circle2L}\circleTwoL,
spath/get components of={circle3L}\circleThreeL,
spath/get components of={circle4L}\circleFourL,
spath/get components of={conn12R}\connOneTwoR,
spath/get components of={conn12L}\connOneTwoL,
spath/get components of={conn34}\connThreeFour,
spath/get components of={split23R}\splitTwoThreeR,
spath/get components of={split23L}\splitTwoThreeL,
spath/get components of={split3Conn34R}\splitThreeConnThreeFourR,
spath/get components of={split4Conn34R}\splitFourConnThreeFourR,
spath/get components of={split3Conn34L}\splitThreeConnThreeFourL,
spath/get components of={split4Conn34L}\splitFourConnThreeFourL,
}
% \end{macrocode}
% Combines appropriate components to draw the shield shape.
% \begin{macrocode}
\draw[
fill=white,
spath/use={\getComponentOf\circleOneR{3}},
spath/use={\getComponentOf\connOneTwoR{2},weld},
spath/use={\getComponentOf\circleTwoR{2},weld},
spath/use={\getComponentOf\circleThreeR{3},reverse,weld},
spath/use={\getComponentOf\connThreeFour{2},weld},
spath/use={\getComponentOf\circleFourR{2},weld},
spath/use={\getComponentOf\circleFourL{2},weld},
spath/use={\getComponentOf\connThreeFour{4},weld},
spath/use={\getComponentOf\circleThreeL{2},reverse,weld},
spath/use={\getComponentOf\circleTwoL{3},weld},
spath/use={\getComponentOf\connOneTwoL{2},reverse,weld},
spath/use={\getComponentOf\circleOneL{3},weld},
spath/adjust and close=current,
];
\node at (0,0) {\sffamily#1};
\end{tikzpicture}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\statehighway}
% A simple pill shape welded together.
% \begin{macrocode}
\newcommand{\statehighway}[1]{%
\begin{tikzpicture}[x=1em,y=1em]
% \end{macrocode}
% These paths make up a pill - a rectangular shape capped
% on both horizontal ends by semicircles.
% \begin{macrocode}
\path[spath/save=top] (-0.5,0.6) -- (0.5,0.6);
\path[spath/save=right] (0.5,0.6) arc (90:-90:0.6);
\path[spath/save=bottom] (0.5,-0.6) -- (-0.5,-0.6);
\path[spath/save=left] (-0.5,-0.6) arc (270:90:0.6);
% \end{macrocode}
% Paths are combined and welded appropriately.
% \begin{macrocode}
\draw[
fill=white,
spath/use={top},
spath/use={right,weld},
spath/use={bottom,weld},
spath/use={left,weld},
spath/adjust and close=current,
];
\node {\sffamily#1};
\end{tikzpicture}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\parking}
% A simple parking, ``P," sign.
% \begin{macrocode}
\newcommand{\parking}{%
\begin{tikzpicture}[x=1em,y=1em]
\node at (0, 0) [rectangle,fill=white,draw=black,rounded corners=0.25em] {\sffamily P};
\end{tikzpicture}
}
% \end{macrocode}
% \end{macro}
%
% \Finale
\endinput