summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/worldflags/doc/worldflags.tex
blob: 982ea883f0c1eafb43a7c4331b60de9c419fd2bc (plain)
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
% =============================================================================
% Flags of the world with TikZ                       Wilhelm Haager, 2021-04-19
% =============================================================================
\documentclass[11pt,a4paper,headsepline]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage[width=150mm,height=230mm]{geometry}
\usepackage{helvet}
\usepackage[bitstream-charter]{mathdesign}
\usepackage{charter}
\usepackage[nottoc,numbib]{tocbibind}  % bibliography as numbered chapter
\usepackage{array}
\usepackage{ragged2e}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{verbatimbox}
\usepackage{xcolor}
\usepackage{pifont}
\usepackage{scrlayer-scrpage}
   \pagestyle{scrheadings}
   \clearpairofpagestyles
   \KOMAoptions{headsepline}
   \setkomafont{pagehead}{\small\rmfamily\slshape}
   \setkomafont{pagenumber}{\small\rmfamily\slshape}
   \lehead{\pagemark}
   \rehead{Worldflags}
   \lohead{Worldflags}
   \rohead{\pagemark}
   \def\chapterheadstartvskip{\vspace*{0mm}}
   \def\chapterpagestyle{scrheadings}
\raggedbottom

\usepackage{worldflags}

\definecolor{emphcolor}{rgb}{0.6,0.1,0}
\definecolor{tablefcolor}{rgb}{0.8,0.7,0.5}
\colorlet{tablecolor}{tablefcolor!40}
\definecolor{codecolor}{rgb}{0.23,0.37,0.17}
\colorlet{cbcolor}{codecolor!20} % codebox background
\colorlet{cfcolor}{codecolor!40} % codebox frame
\colorlet{ctcolor}{codecolor!60} % codebox text
\definecolor{rcolor}{rgb}{1,0.66,0.14}
\colorlet{rbcolor}{rcolor!20} % resultbox background
\colorlet{rfcolor}{rcolor!50} % resultbox frame
\colorlet{rtcolor}{rcolor!80} % resultbox text

\def\tb{\textbackslash}
\let\ti=\textit
\let\tt=\texttt
\def\m{\mbox{}}
\def\xx#1{\mbox{}\foreach \n in {1,...,#1}{~}}
\def\colwidth{45mm} % with of the left hand column in tables
\def\command#1{{\color{emphcolor}\texttt{#1}}}

\parskip\bigskipamount
\parindent0pt
\newcount\zaehler\zaehler0
\def\show#1#2{%
 \advance\zaehler by 1
 \parbox{0.23\textwidth}{%
    \centering
    \worldflag{#2}\\
    {\small #1\\[-\smallskipamount](#2)}}
 \ifnum\zaehler=4\zaehler=0\par\fi
}

% ------------------------------------------------------------------------
% Frames
% ------------------------------------------------------------------------

\long\def\wideframe#1{{\fboxsep5mm\fboxrule0.5pt%
  \newdimen\pbwidth\pbwidth\textwidth
  \advance\pbwidth by -2\fboxsep
  \advance\pbwidth by -2\fboxrule
  \fcolorbox{tablefcolor}{tablecolor}%
  {\begin{minipage}{\pbwidth}#1\end{minipage}}}}

\long\def\codebox#1#2{\begin{minipage}[t]{#1\textwidth}
  \fboxsep1mm\fboxrule0.5pt%
  \newdimen\pbwidth\pbwidth\textwidth
  \advance\pbwidth by -2\fboxsep
  \advance\pbwidth by -2\fboxrule
  \fcolorbox{cfcolor}{cbcolor}%
  {\begin{minipage}[t]{\pbwidth}%
  {\footnotesize\sffamily\bfseries\color{ctcolor}Code:\\[\smallskipamount]}%
  \footnotesize\ttfamily\color{codecolor}#2\end{minipage}}
  \end{minipage}}

\long\def\resultbox#1#2{\begin{minipage}[t]{#1\textwidth}
  \fboxsep1mm\fboxrule0.5pt%
  \newdimen\pbwidth\pbwidth\textwidth
  \advance\pbwidth by -2\fboxsep
  \advance\pbwidth by -2\fboxrule
  \fcolorbox{rfcolor}{rbcolor}%
  {\begin{minipage}[t]{\pbwidth}%
  {\footnotesize\sffamily\bfseries\color{rtcolor}Result:\\[\smallskipamount]}%
  \small#2\end{minipage}}
  \end{minipage}}

% Weird hack from stackexchange to enable § as shortverb-character with utf8:
\begingroup\uccode`~="C2 \uppercase{\endgroup
\DeclareUnicodeCharacter{00A7}{\verb~}}
\begingroup\uccode`~="A7 \uppercase{\endgroup\def~}{}

\begin{document}
% --------------------------------------------------------------------------
% titlepage
% --------------------------------------------------------------------------
\title{Worldflags}
\subtitle{Drawing flags with TikZ}
\author{\slshape Wilhelm Haager\\\slshape wilhelm.haager@htlstp.ac.at}
\vfill
\vfill
\date{Version 1.0\\\today}
\vfill
\maketitle

% --------------------------------------------------------------------------
% table of contents
% --------------------------------------------------------------------------
 \tableofcontents

% --------------------------------------------------------------------------
\chapter{Introduction}
% --------------------------------------------------------------------------

\emph{Worldflags} is a package for drawing flags using TikZ.
Currently the national flags of all independent nations are included,
additionally some other flags of various organizations;
there's more to come.

A particular flag is selected via a parameter; for national flags that is the
two-letter country code (i.\,e. the domain name).
A flag can be drawn in two ways:
\begin{itemize}
\item As a single TikZ-picture within ordinary text.
\item As a picture element \emph{within} a TikZ-picture.
\end{itemize}

The appearance of a flag (size, frame etc.) can be adapted using
optional parameters.

The description of every flag resides in a particular flag description file
{\color{emphcolor}\texttt{worldflag\_}\textit{xx}\texttt{.tex}},
wherein \textit{xx} is the parameter for selecting a particular flag,
as listed in section \ref{FLAGS}.
That saves memory and computing time on the one hand,
as only the required flags have to be loaded.
On the other hand, the package can easily be extended by adding new
flag description files.

Some flags with complicated emblems (e.\,g. Afghanistan, Ecuador)
require a lot of memory. Thus an expansion of \TeX's main memory size
is recommended.

The flag descriptions are based on the construction sheets in
\cite{VEXILLAMUNDI}
(thanks to Mello Luchten\-berg for that great website),
complex emblems have been taken from the svg-files on Wikipedia
and have been translated into Tikz via Inkscape
(with a reasonable amount of manual post editing).

% --------------------------------------------------------------------------
\chapter{Usage}
% --------------------------------------------------------------------------

\section{Flags as single TikZ-pictures}
% ------------------------------------------------
%{\color{emphcolor}§worldflag[§\textit{opts}§]{§\textit{xx}§}§} draws the flag
%\textit{xx} with the Options \textit{opts}.  \the\textwidth

% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\wideframe{
\textsl{Commands:}\\[\medskipamount]
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}X@{}}
{\m\color{emphcolor}\texttt{\tb worldflag[}\textit{opts}\texttt{]\{}\textit{xx}\texttt{\}}}
&
draws the flag \textit{xx} with the optional parameters \textit{opts} as a particular TikZ-picture.\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb flagsdefault[}\textit{opts}\texttt{]}}
&
sets default values for the options \textit{opts} for subsequent flags.
\end{tabularx}

\bigskip
\textsl{Options:}\\[\medskipamount]
\begin{tabularx}{\textwidth}{@{}p{\colwidth}X@{}}
{\m\color{emphcolor}\texttt{width=}\textit{dimension}}
&
sets the flag width, default: $15\,\mathrm{mm}$.\\[\medskipamount]
{\m\color{emphcolor}\texttt{length=}\textit{dimension}}
&
sets the flag length; if set to 0\,pt (default), the length is calculated according to the proper aspect ratio of the flag.\\[\medskipamount]
{\m\color{emphcolor}\texttt{framewidth=}\textit{dimension}}
&
sets the line width of the frame around the flag, default: 0.2\,mm.\\[\medskipamount]
{\m\color{emphcolor}\texttt{framecolor=}\textit{colorname}}
&
sets the color of the flag frame, default: \texttt{black!60}.\\[\medskipamount]
{\m\color{emphcolor}\texttt{stretch=}\textit{number}}
&
controls stretching and shrinking of geometric shapes when the aspect ratio differs from its proper value.\\[\medskipamount]
{\m\color{emphcolor}\texttt{grid}}
&
causes a millimeter-grid drawn on the flag as an aid for constructing new flags.\\[\medskipamount]
{\m\color{emphcolor}\texttt{noemblem}}
&
supresses the drawing of an emblem, which is part of many flags.\\[\medskipamount]
{\m\color{emphcolor}\texttt{emblem}}
&
enforces the drawing of an emblem onto the flag which is otherwise supressed (currently only applies to the flags of Austria and Germany).\\[\medskipamount]
{\m\color{emphcolor}\texttt{emblemdefault}}
&
restores the default behavior for drawing emblems.\\[\medskipamount]
\end{tabularx}}
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\bigskip
\command{\tb worldflag\{{\rmfamily\itshape xx}\}} draws a flag,
selected by the parameter \textit{xx}, as a single TikZ-picture.
Section \ref{FLAGS} lists all available flags and their selection code \textit{xx}.
Various properties of the flag can be specified with additional optional parameters
as key-value pairs.

\command{\tb flagsdefault[{\rmfamily\itshape opts}]} specifies default values
for the Options {\rmfamily\itshape opts} for subsequent flags.

The \emph{width} of a flag defaults to 15\,mm, it can be overridden with the option
\command{width}.
If one of the dimensions \emph{width} or \emph{length} is set to 0\,pt
(which is the default value for \emph{length}), its value
results from the proper aspect ratio width/length, which is proprietary to every flag.
E.\,g. the Swiss flag is quadratic, it has an aspect ratio of 1:1,
the British flag has an aspect ratio of 1:2.
If \command{width} is set to 0\,pt, \command{length} \emph{must} be specified.
If both dimensions are specified, flags loose their proper aspect ratio
but get the same size:

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.45}{\tb worldflag\{CH\}\\\tb worldflag\{GB\}\\
   proper sizes\tb\tb[6pt]\\
   \tb worldflag[length=22.5mm]\{CH\}\\\tb worldflag[length=22.5mm]\{GB\}\\
   distorted}\hfill
\resultbox{0.54}{\worldflag{CH} \worldflag{GB} proper sizes\\[6pt]
   \worldflag[length=22.5mm]{CH} \worldflag[length=22.5mm]{GB} distorted}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\medskip
If both width and length of a flag are specified, which differs from ist
proper aspect ratio, some geometries on the flag will unavoidably
get distorted.
There is presumably no general rule whether certain \emph{distances} on the flag
should remain unchanged in that case, or certain \emph{ratios}
-- as flag owners do not intend to distort their flags --
but that behavior can be influenced for many flags applying the option
\command{stretch}.
If stretch is set to 0 (which is default), certain \emph{distances} and
\emph{sizes} on the flag remain unchanged, when the flag is stretched;
if set to 1, certain \emph{ratios} remain unchanged in that case.
Values within the range of 0\dots 1 are possible to get a compromise
between both cases.

The following examples illustrate that behavior:

\begin{tabularx}{\textwidth}{@{}llX@{}}
Canada: & \command{stretch=0} & The \emph{size} of the maple leaf remains unchanged.\\
        & \command{stretch=1} & The \emph{ratio} of the widths -- maple leaf and pale -- remains unchanged; the maple leaf has to shrink.
\end{tabularx}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.45}{
   \tb flagsdefault[width=12mm]
   \tb worldflag\{CA\}\\
   \tb worldflag[length=18mm]\{CA\}\\
   \tb worldflag[length=18mm,stretch=1]\{CA\} }\hfill
\resultbox{0.54}{%
   \flagsdefault[width=12mm]
   \worldflag{CA}
   \worldflag[length=18mm]{CA}
   \worldflag[length=18mm,stretch=1]{CA}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\begin{tabularx}{\textwidth}{@{}llX@{}}
Denmark: & \command{stretch=0} & The \emph{distance} from the vertical bar to the hoist remains unchanged.\\
         & \command{stretch=1} & The \emph{ratio} of the distances to the hoist and to the fly remains unchanged.
\end{tabularx}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.45}{
   \tb flagsdefault[width=12mm]
   \tb worldflag\{DK\}\\
   \tb worldflag[length=18mm]\{DK\}\\
   \tb worldflag[length=18mm,stretch=1]\{DK\} }\hfill
\resultbox{0.54}{%
   \flagsdefault[width=12mm]
   \worldflag{DK}
   \worldflag[length=25mm]{DK}
   \worldflag[length=25mm,stretch=1]{DK}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\medskip
The option \command{grid} causes a millimeter-grid drawn over the flag.
That is primarily a measuring aid for the construction of new flags.

The options \command{framecolor} and \command{framewidth} set the color
and the line width of the frame drawn around the flag, respectively.
The default value for the line width is 0.2\,mm, the default color is
\texttt{black!60}.
If \command{framewidth} is set to 0\,mm (or 0\,pt), no frame is drawn at all.

\flagsdefault[length=0mm,width=15mm]
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.45}{
   \tb flagsdefault[framecolor=blue]
   \tb worldflag[grid]\{IT\}\\
   \tb worldflag[framewidth=1mm]\{IT\}\\
   \tb worldflag[framewidth=0mm]\{IT\} }\hfill
\resultbox{0.54}{%
   \flagsdefault[framecolor=blue]
   \worldflag[grid]{IT}
   \worldflag[framewidth=1mm]{IT}
   \worldflag[framewidth=0mm]{IT}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\medskip
Many flags have an emblem on it,
e.\,g. a coat of arms or a special symbol.
Those emblems are often very complex and require a lot of computing time and
memory.
The depiction of such an emblem can be supressed with the option
\command{noemblem}, either for the sake of saving computing time
(for dafts) or just because simplified version of the flag is required.
Some countries distinguish between a \emph{civil} flag without an emblem
and a \emph{state} flag containing an emblem.

Some flags don't have an emblem by default, but an emblem is available
for special purposes.
In that case the depiction of the emblem can be enforced with the option
\command{emblem}.
Currently that only applies to the country flags of Austria and Germany
(more will come).
The option \command{emblemdefault} restores the default behavior for drawing
emblems.


\flagsdefault[length=25mm,width=15mm]
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.45}{%
   \tb worldflag\{AT\}\\
   \tb worldflag[emblem]\{AT\}\\
   \tb worldflag[noemblem]\{AT\}\tb\tb[6pt]\\
   \tb worldflag\{HR\}\\
   \tb worldflag[emblem]\{HR\}\\
   \tb worldflag[noemblem]\{HR\}%
   }\hfill
\resultbox{0.54}{%
   \worldflag{AT}
   \worldflag[emblem]{AT}
   \worldflag[noemblem]{AT}\\[6pt]
   \worldflag{HR}
   \worldflag[emblem]{HR}
   \worldflag[noemblem]{HR}%
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\medskip
The emblem (i.\,e. the coat of arms) in the Austrian flag is supressed by default,
the emblem in the Croatian flag is depicted default.

\section{Flags as picture elements within a TikZ-picture}\label{SECTION_PIC}
% ------------------------------------------------

Within a Tikz-picture the flags are available as \emph{pic}-Elements
named \command{worldflag}.
A particular flag is selectet with the option \command{country}.
Unlike \emph{nodes}, \emph{pic}-elements cannot be referenced by name,
but named nodes and coordinates within the \emph{pic}-element can be referenced.
Hence every flag has special coordinates for referencing:

\qquad{\divide\tabcolsep by 3
\begin{tabular}{@{}lclllcl}
\command{-0}  & \dots & center of flag &~~~& & & \\
\command{-nw} & \dots & upper left corner  (``north-west'')&~~~& \command{-n} & \dots & top edge center (``north'') \\
\command{-ne} & \dots & upper right corner (``north-east'')&~~~& \command{-e} & \dots & fly edge center (``east'') \\
\command{-sw} & \dots & lower left corner  (``south-west'') &~~~& \command{-w}& \dots & hoist edge center (``west'')  \\
\command{-se} & \dots & lower right corner (``south-east'') &~~~& \command{-s}& \dots & bottom edge center (``south'')
\end{tabular}
}

\newpage


% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\wideframe{
\textsl{Commands:}\\[\medskipamount]
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}X@{}}
{\m\color{emphcolor}\makebox[0pt][l]{\texttt{\tb pic (}\textit{xy}\texttt{) [country=}\textit{xx\,, \dots}\texttt{]~at }\textit{pos}\texttt{ \{worldflag\};}}}
& \\
& draws the flag \textit{xx} and gives it the name \textit{xy}; the flag is centerd at the coordinate \textit{pos}.\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb flagsdefault[}\textit{opts}\texttt{]}}
&
sets default values for the options \textit{opts}.
\end{tabularx}

\bigskip
\textsl{Options:}\\[\medskipamount]
\begin{tabularx}{\textwidth}{@{}p{\colwidth}X@{}}
{\m\color{emphcolor}\texttt{width=}\textit{dimension}}
&
sets the flag width, default: $15\,\mathrm{mm}$.\\[\medskipamount]
{\m\color{emphcolor}\texttt{length=}\textit{dimension}}
&
sets the flag length; if set to 0\,pt (default), the length is calculated according to the proper aspect ratio of the flag.\\[\medskipamount]
{\m\color{emphcolor}\texttt{framewidth=}\textit{dimension}}
&
sets the line width of the frame around the flag, default: 0.2\,mm.\\[\medskipamount]
{\m\color{emphcolor}\texttt{framecolor=}\textit{colorname}}
&
sets the color of the flag frame, default: \texttt{black!60}.\\[\medskipamount]
{\m\color{emphcolor}\texttt{stretch=}\textit{number}}
&
controls stretching and shrinking of geometric shapes when the aspect ratio differs from its proper value.\\[\medskipamount]
{\m\color{emphcolor}\texttt{grid}}
&
causes a millimeter-grid drawn on the flag.\\[\medskipamount]
{\m\color{emphcolor}\texttt{noemblem}}
&
supresses the drawing of an emblem onto the flag.\\[\medskipamount]
{\m\color{emphcolor}\texttt{emblem}}
&
enforces the drawing of an emblem onto the flag.\\[\medskipamount]
{\m\color{emphcolor}\texttt{emblemdefault}}
&
restores the default behavior for drawing emblems.\\[\medskipamount]
{\m\color{emphcolor}\texttt{rotate=}$\alpha$}
&
rotates the flag $\alpha$ degrees around its center.\\[\medskipamount]
{\m\color{emphcolor}\texttt{turn=}$\beta$}
&
rotates the flag $\beta$ degrees around the (imaginary) flagpole.\\[\medskipamount]
{\m\color{emphcolor}\texttt{hang=}$\gamma$}
&
lets the flag ``hang down'' $\gamma$ degrees from the (imaginary) flag pole.\\[\medskipamount]
\end{tabularx}}
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The following example illustrates the usage of the special coordinates:

\flagsdefault[length=25mm,width=15mm]
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.63}{%
   \tb begin{tikzpicture}[draw=cyan,>=stealth,x=1mm,y=1mm]\\
   \tb draw (de-e){-}-++(45:5) node [above right,cyan] \{fly\};\\
   \tb draw (de-w)--++(45:14)\\\mbox{}~~~~~~node [above right,cyan] \{hoist\};\\
   \tb draw (de-0)--++(45:14)\\\mbox{}~~~~~~node [above right,cyan] \{coat of arms\};\\
   \tb draw (de-nw)--++(-5,0) (de-sw)--++(-5,0);\\
   \tb draw [<->] (\$(de-nw)-(4,0)\$){-}-(\$(de-sw)-(4,0)\$)\\\mbox{}~~~~~~node [midway,above,rotate=90,cyan] \{width\};\\
   \tb draw [<->] (\$(de-sw)-(0,6)\$){-}-(\$(de-se)-(0,6)\$)\\\mbox{}~~~~~~node [midway,above,cyan] \{length\};\\
   \tb end{tikzpicture}%
   }\hfill
\resultbox{0.36}{%
   \begin{tikzpicture}[draw=cyan,>=stealth,x=1mm,y=1mm]
   \pic (de) [country=DE,emblem] {worldflag};
   \draw (de-e)--++(45:5) node [above right,cyan] {fly};
   \draw (de-w)--++(45:14) node [above right,cyan] {hoist};
   \draw (de-0)--++(45:14) node [above right,cyan] {coat of arms};
   \draw (de-nw)--++(-5,0) (de-sw)--++(-5,0);
   \draw [<->] ($(de-nw)-(4,0)$)--($(de-sw)-(4,0)$) node [midway,above,rotate=90,cyan] {width};
   \draw (de-sw)--++(0,-7) (de-se)--++(0,-7);
   \draw [<->] ($(de-sw)-(0,6)$)--($(de-se)-(0,6)$) node [midway,above,cyan] {length};
   \end{tikzpicture}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

% **************************************************************************
% \fi % Ende Kommentar
% **************************************************************************

\newpage
The option \command{rotate} causes the flag to be rotated around the
flag center with a given angle in degree.

Note: That option is not proprietary to flags, it is a general option for
\emph{any} {pic}-element.
Hence it is \emph{not} possible to give it a default value
% -- unlike all other options --
with the command \texttt{flagsdefault}.

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.53}{%
   \tb begin\{tikzpicture\}\\
   \tb flagsdefault[width=12mm,length=18mm]\\
   \tb foreach \tb c/\tb n in \{HU/0,SK/1,IT/6,SI/7\}\\
   \xx3\tb pic [country=\tb c,rotate=\tb n*45]\\
   \xx7 at (\tb n*45:24mm) \{worldflag\};\\
   \tb foreach \tb c/\tb n in \{CZ/2,DE/3,LI/4,CH/5\}\\
   \xx3\tb pic [country=\tb c,rotate=\tb n*45-180]\\
   \xx7 at (\tb n*45:24mm) \{worldflag\};\\
   \tb end\{tikzpicture\}
   }\hfill
\resultbox{0.46}{%
   \begin{tikzpicture}
   \flagsdefault[width=12mm,length=18mm]
   \foreach \c/\n in {HU/0,SK/1,IT/6,SI/7}
   \pic [country=\c,rotate=\n*45] at (\n*45:24mm) {worldflag};
   \foreach \c/\n in {CZ/2,DE/3,LI/4,CH/5}
   \pic [country=\c,rotate=\n*45-180] at (\n*45:24mm) {worldflag};
   \end{tikzpicture}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The option \command{turn} lets the flag rotate around the imaginary flagpole
with a given angle $\beta$ (in degrees).
The length of the flag will \emph{seemingly} shrink with a factor of $\cos\beta$.
With a value of $\beta\!=\!180$ the flag will just appear mirrored.
The option \command{hang} lets the flag ``hang down'' from the imaginary flagpole
with a given angle $\gamma$ (in degrees);
the flag will be sheared and compressed accordingly.

The following example shows a combination of
\command{rotate}, \command{turn} and \command{hang}.

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.53}{%
   \tb begin\{tikzpicture\}[x=1mm,y=1mm]\\
   \tb def\tb w\{30\}\\
   \tb def\tb d\{20\}\\
   \tb pgfdeclarehorizontalshading\{flagpole\}\\
   \xx3\{30mm\}\{color(0mm)=(white);\\
   \xx3color(1mm)=(brown); color(2mm)=(black)\}\\
   \tb flagsdefault[width=15mm,hang=20]\\
   \tb pic (gb) [country=GB,rotate=-\tb w]\\
   \xx5at (\tb d,0) \{worldflag\};\\
   \tb pic (us) [country=US,rotate=\tb w,turn=180]\\
   \xx5at (-\tb d,0) \{worldflag\};\\
   \tb fill [shading=flagpole,shading angle=-\tb w,\\
   \xx6rotate around=\{-\tb w:(gb-nw)\}]\\
   \xx6(gb-nw)-|++(-2,-60)-|cycle;\\
   \tb fill [shading=flagpole,shading angle=\tb w,\\
   \xx6rotate around=\{\tb w:(us-nw)\}]\\
   \xx6(us-nw)-|++(2,-60)-|cycle;\\
   \tb end\{tikzpicture\}
   }\hfill
\resultbox{0.46}{%
   \begin{tikzpicture}[x=1mm,y=1mm]
   \def\w{30}
   \def\d{20}
   \pgfdeclarehorizontalshading{flagpole}{30mm}
   {color(0mm)=(white); color(1mm)=(brown); color(2mm)=(black)}
   \flagsdefault[width=15mm,hang=20]
   \pic (gb)[country=GB,rotate=-\w] at (\d,0) {worldflag};
   \pic (us)[country=US,rotate=\w,turn=180] at (-\d,0) {worldflag};
   \fill [shading=flagpole,shading angle=-\w,rotate around={-\w:(gb-nw)}] (gb-nw)-|++(-2,-60)-|cycle;
   \fill [shading=flagpole,shading angle=\w,rotate around={\w:(us-nw)}] (us-nw)-|++(2,-60)-|cycle;
   \end{tikzpicture}
   }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

% --------------------------------------------------------------------------
\chapter{Internals}
% --------------------------------------------------------------------------

This section is intended for those who want to \emph{extend} the worldflag
package and {create} new flags.
Those who just want to \emph{use} the package and {draw} existing flags,
need not read it.

Evey flag resides in a particular ``flag description file''
named \command{worldflag\_}\textit{\color{emphcolor}xx}\command{.tex}, wherein
\textit{\color{emphcolor}xx} is the code for selecting a flag.
Extending the package with new flags is quite easy:
Just a flag description file for every new flag has to be written and put into
a directory, where \TeX\ can find it.
No configuraion files, no other actions; that's it.

\section{Flag description file}\label{SEC_FLAG_DESCRIPTION}
% -----------------------------

Every flag description file has the following structure:

{\color{emphcolor}\small
\tt{\tb BeginFlagDescription\{}\ti{y}\tt{\}\{}\ti{x}\tt{\}}~~~{\normalsize\color{black}\ding{192}}\\
\tt{\tb definecolor\{red\}\{RGB\}\{}\ti{r}\tt{,}\ti{g}\tt{,}\ti{b}\tt{\}}~~~{\normalsize\color{black}\ding{193}}\\
\tt{\tb definecolor\{gold\}\{RGB\}\{}\ti{r}\tt{,}\ti{g}\tt{,}\ti{b}\tt{\}}\\
\xx9\makebox[0pt]{$\vdots$}\\
\xx9{\makebox[0pt]{\normalsize\color{black}\ding{194}}}\\
\xx9\makebox[0pt]{$\vdots$}\\
\tt{\tb FrameCode}~~~{\normalsize\color{black}\ding{195}}\\
\tt{\tb EndFlagDescription}~~~{\normalsize\color{black}\ding{196}}\\
}

\begin{itemize}
\item[\ding{192}]
This command calculates the flag length,
which will be stored in the dimension register \command{\tb flaglength}, from
the flag width, which is stored in the dimension register \command{\tb flagwidth}
(or vice versa) using the proper aspect ratio of the flag.
That aspect ratio has to be specified with the two parameters
{\color{emphcolor}\ti{y}} (width) and {\color{emphcolor}\ti{x}} (length).
Those parameters have to be interger numbers,
their absolute values don't matter.

Furthermore, two nested scopes are opened:
The outer scope sets the drawing unit to \command{\tb flagwidth}
(note: the top edge of a flag has always a \ti{y}-coordinate of 1)
and performs the coordinate transformation according to the options
\command{turn} and \command{hang}.
The inner scope shifts the coordinate system to the flag center.

In the sequel, the special coordinates
\command{-0}, \command{-n}, \command{-ne}, \command{-e}, \command{-se},
\command{-s}, \command{-sw}, \command{-w} and \command{-nw}
are established -- as described in section \ref{SECTION_PIC}.

\item[\ding{193}]
Every flag has proprietary shadings of colors.
Hence even common colors have to be redefined for every flag separately.

\item[\ding{194}]
TikZ commands for drawing and filling of shapes make up the core of
a flag description file.
A couple of macros (see section \ref{SEC_MACROS})
for common geometric figures facilitate the creation of the flag image.

\item[\ding{195}]
This command draws a rectangular frame around the flag.
The line width, set with the option \command{framewidth}, is stored in the
dimension register \command{\tb flagframe};
the frame color, set with the option \command{framecolor}, is stored in the
macro \command{\tb framecolor}.
For non-rectangular flags (e.\,g. Nepal) the flag frame has to be programmed
``manually''.

\item[\ding{196}]
This command draws a millimeter-grid onto the flag, if invoked with the option
\command{grid} and closes the two previously opened scopes.
\end{itemize}

\section{Variables}
% -----------------

A couple of properties of a flag are kept in variables,
which are either dimension registers or macros.
Those variables are set by the user, specifying options or are calculated
internally.
They are used in the code for the flag description,
but need not be set directly.

 % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\wideframe{
\textsl{Dimension registers:}\\[\medskipamount]
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}X@{}}
{\m\color{emphcolor}\texttt{\tb flagwidth}}
&
width of the flag (vertical extent)\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb flaglength}}
&
length of the flag (horizontal extent)\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb flagframe}}
&
line width of the flag frame\\[\medskipamount]
\end{tabularx}

\bigskip
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}X@{}}
\textsl{Macros:}\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb framecolor}}
&
color name of the flag frame\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb viewangle}}
&
angle of the rotation around the flagpole\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb hangangle}}
&
angle of the ``hanging down'' from the flagpole\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb flagstretch}}
&
conrols stretching of certain geometries, when stretching the entire flag\\[\medskipamount]
{\m\color{emphcolor}\texttt{\tb StretchFactor}}
&
factor for stretching of certain geometries according to \tt{\tb flagstretch}\\[\medskipamount]
\end{tabularx}}
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\command{\tb flagwidth} and \command{\tb flaglength} specify the width and
length of a flag.
They are set by the user with the options \command{width} and \command{length}
or are calculaterd from each other by \command{\tb AspectRatio} internally.
\command{\tb flagwidth} is the unit for coordinates and lengths
in the flag description.

The properties of the flag frame are kept in the variables
\command{\tb flagframe} and \command{\tb framecolor};
they can be set with the options
\command{framewidth} and \command{framecolor}.

\command{\tb StretchFactor} is a factor for stretching certain \ti{x}-coordinates,
when the whole flag is stretched (or compressed),
i.\,e. when the aspect ratio differs from its proper value.
It is calculated by \command{\tb AspectRatio}
from the variable \command{\tb flagstretch},
which itself is user-specified with the Option \command{stretch}.

\section{Commands}\label{SEC_MACROS}
% ----------------------------------

 % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\wideframe{
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}>{\RaggedRight}X@{}}
{\m\color{emphcolor}\tt{\tb BeginFlagDescription\{}\ti{y}\tt{\}\{}\ti{x}\tt{\}}}
&
\qquad\qquad see section \ref{SEC_FLAG_DESCRIPTION}\\[\medskipamount]
{\m\color{emphcolor}\tt{\tb EndFlagDescription}}
&
see section \ref{SEC_FLAG_DESCRIPTION}\\[\medskipamount]
{\m\color{emphcolor}\tt{\tb AspectRatio\{}\ti{y}\tt{\}\{}\ti{x}\tt{\}}}
&
calculates the dimensions of the flag and the\newline variable \tt{\tb StretchFactor}; called by \tt{\tb BeginFlagDescription}.\\[\medskipamount]
{\m\color{emphcolor}\tt{\tb FrameCode}}
&
draws the rectangular frame around the flag.\\[\medskipamount]
{\m\color{emphcolor}\tt{\tb GridCode}}
&
draws a millimeter-grid onto the flag; called by \tt{\tb EndFlagDescription}.\\[\medskipamount]
\end{tabularx}

\bigskip
\begin{tabularx}{\textwidth}{@{}>{\RaggedRight}p{\colwidth}X@{}}
\textsl{Geometric flag elements:}
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb hstripesII\{}{$c_1$}\tt{\}\{}{$c_2$}\tt{\}}}
& partitions the flag into two horizontal stripes with the colors $c_1$ and $c_2$.
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb hstripesIII\{}{$c_1$}\tt{\}\{}{$c_2$}\tt{\}\{}{$c_3$}\tt{\}}}
& three horizontal stripes with the colors $c_1$, \dots
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb hstripesIV\{}{$c_1$}\tt{\}\{}{$c_2$}\tt{\}\{}{$c_3$}\tt{\}\{}{$c_4$}\tt{\}}}
& \qquad four horizontal stripes with the colors $c_1$, \dots
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb vstripesII\{}{$c_1$}\tt{\}\{}{$C_2$}\tt{\}}}
& partitions the flag into two vertical stripes with the colors $c_1$ and $c_2$.
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb vstripesIII\{}{$c_1$}\tt{\}\{}{$c_2$}\tt{\}\{}{$c_3$}\tt{\}}}
& three vertical stripes with the colors $c_1$, \dots
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb hbar\{}{$c$}\tt{\}\{}{$y$}\tt{\}\{}{$w$}\tt{\}}}
& horizontal bar with the color $c$ and the line width $w$ at the \ti{y}-coordinate $y$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb vbar\{}{$c$}\tt{\}\{}{$x$}\tt{\}\{}{$w$}\tt{\}}}
& vertical bar with the color $c$ and the line width $w$ at the \ti{x}-coordinate $x$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb chevron\{}{$c$}\tt{\}\{}{$x$}\tt{\}}}
& isosceles triangle at the hoist with the color $c$ and the vertex at the \ti{x}-coordinate $x$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb starV\{}{$c$}\tt{\}\{}{$p$}\tt{\}\{}{$r$}\tt{\}\{}{$\alpha$}\tt{\}}}
& 5-pointed star as a compex polygon with the fill color $c$, an outer raduis $r$, an angle $\alpha$ at the coordinate $p$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb starVI\{}{$c$}\tt{\}\{}{$p$}\tt{\}\{}{$r$}\tt{\}\{}{$\alpha$}\tt{\}}}
& 6-pointed star as a compex polygon with the fill color $c$, an outer raduis $r$, an angle $\alpha$ at the coordinate $p$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb starn\{}{$c$}\tt{\}\{}{$n$}\tt{\}\{}{$p$}\tt{\}\{}{$r_1$}\tt{\}\{}{$r_2$}\tt{\}\{}{$\alpha$}\tt{\}}}
& \qquad n-pointed star with the fill color $c$, an outer raduis $r_a$, an inner raduis $r_i$ and an angle $\alpha$ at the coordinate $p$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb moon\{}{$c$}\tt{\}\{}{$p_1$}\tt{\}\{}{$r_1$}\tt{\}\{}{$p_2$}\tt{\}\{}{$r_2$}\tt{\}}}
& crescent moon with the fill color $c$, as a difference set of two generating circles with the radii $r_1$, $r_2$, and center coordinates $p_1$ and $p_2$
\\[\medskipamount] % --------------------------
{\m\color{emphcolor}\tt{\tb UnionJack\{}{$x_1$}\tt{\}\{}{$y_1$}\tt{\}\{}{$x_2$}\tt{\}\{}{$y_2$}\tt{\}}}
& \qquad Union Jack between the coordinates $(x_1,y_1)$ and $(x_2,y_2)$
\\[\medskipamount] % --------------------------
\end{tabularx}}
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The macros
\command{\tb hstripesII}, \command{\tb hstripesIII}, \command{\tb hstripesIV},
\command{\tb vstripesII}, \command{\tb vstripesIII} partition the flag into an
according number of horizontal or vertical colored stripes.
\command{\tb hbar} draws a horizontal bar of given width and color
at a specified \ti{y}-coordinate across the flag;
\command{\tb vbar} does the same vertically.
\command{\tb chevron} draws an isosceles triangle with a given height over
the hoist.
Those macros need to know the variables \command{\tb flagwidth} and
\command{\tb flaglength} which have to be defined, if called
outside a flag description file:

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.65}{%
   \tb newdimen\tb flagwidth\tb flagwidth=15mm \\
   \tb newdimen\tb flaglength\tb flaglength=20mm\\\\
   \tb begin\{tikzpicture\}[x=\tb flagwidth,y=\tb flagwidth]\\
   \tb begin\{scope\}\tb hstripesIII\{cyan\}\{white\}\{red\} \\
   \xx3\tb FrameCode\tb end\{scope\}\\
   \tb begin\{scope\}[shift={(1.5,0)}]\\
   \xx3\tb vstripesIII\{cyan\}\{white\}\{red\} \\
   \xx3\tb FrameCode\tb end\{scope\}\\
   \tb begin\{scope\}[shift=\{(0,-1.2)\}]\\
   \xx3\tb hbar\{cyan\}\{0.5\}\{1\}\\
   \xx3\tb hbar\{white\}\{0.5\}\{0.3\}\\
   \xx3\tb vbar\{white\}\{0.5\}\{0.3\}\\
   \xx3\tb FrameCode\tb end\{scope\}\\
   \tb begin\{scope\}[shift={(1.5,-1.2)}]\\
   \xx3\tb chevron\{cyan\}\{1\}\tb FrameCode\tb end\{scope\}
   \tb end\{tikzpicture\}
   }\hfill
\resultbox{0.34}{%
   \newdimen\flagwidth\flagwidth=15mm
   \newdimen\flaglength\flaglength=20mm
   \begin{tikzpicture}[x=\flagwidth,y=\flagwidth]
   \begin{scope}
     \hstripesIII{cyan}{white}{red}
     \FrameCode
   \end{scope}
   \begin{scope}[shift={(1.5,0)}]
     \vstripesIII{cyan}{white}{red}
    % \FrameCode
   \end{scope}
   \begin{scope}[shift={(0,-1.2)}]
     \hbar{cyan}{0.5}{1}
     \hbar{white}{0.5}{0.3}
     \vbar{white}{0.5}{0.3}
     \FrameCode
   \end{scope}
   \begin{scope}[shift={(1.5,-1.2)}]
     \chevron{cyan}{1}
     \FrameCode
   \end{scope}
%   \begin{scope}[shift={(0,-2.4)}]
%     \colorlet{blue}{cyan}
%     \UnionJack{0mm}{0.5\flagwidth}{0.8\flaglength}{\flagwidth}
%     \FrameCode
%   \end{scope}
   \end{tikzpicture}
}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: A flag needs no background.

The following commands don't require the variables
\command{\tb flagwidth} and \command{\tb flaglength};
they can be used arbitrarily outside a flag, anywhere in a TikZ-picture.

\command{\tb Union Jack} draws the Union Jack
(which is part of a couple of flags)
between a lower left and an upper right point.
Their coordinates -- $x_1$, $y_1$, $x_2$,$y_2$ -- are separate
parameters, which \emph{must} be specified as dimensions
(i.\,e. using a unit), not just as numbers.
The colors \command{blue}, \command{red} and \command{white}
can be redefined arbitrarily.

The various types of stars \command{\tb starV} \command{\tb starVI}
\command{\tb starn} and \command{\tb moon} are self-explanatory.
In the following example \tt{\tb starn} and \tt{\tb moon}
are overlayed with the generating circles.

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\codebox{0.65}{%
   \tb begin\{tikzpicture\}[x=1mm,y=1mm]\\
   \tb UnionJack\{0mm\}\{0mm\}\{30mm\}\{15mm\}\\
   \tb colorlet\{blue\}\{cyan\}           \\
   \tb definecolor\{red\}\{rgb\}\{0.8,0,0\} \\
   \tb UnionJack\{32mm\}\{0mm\}\{47mm\}\{15mm\}\\
   \tb begin\{scope\}[shift=\{(12,-28)\}]\\
   \xx3\tb starV\{cyan\}\{(0,17)\}\{6\}\{0\}\\
   \xx3\tb starVI\{cyan\}\{(22,17)\}\{6\}\{0\}\\
   \xx3\tb starn\{cyan\}\{9\}\{(22,0)\}\{8\}\{3\}\{0\}\\
   \xx3\tb draw[gray] (22,0)circle(8) (22,0)circle(3);\\
   \xx3\tb moon\{cyan\}\{(0,0)\}\{8\}\{(4,2)\}\{7\}\\
   \xx3\tb draw[gray] (0,0)circle(8) (4,2)circle(7);\\
   \tb end\{scope\}\\
   \tb end\{tikzpicture\}
   }\hfill
\resultbox{0.34}{%
   \begin{tikzpicture}[x=1mm,y=1mm]
   \UnionJack{0mm}{0mm}{30mm}{15mm}
   \colorlet{blue}{cyan}
   \definecolor{red}{rgb}{0.8,0,0}
   \UnionJack{32mm}{0mm}{47mm}{15mm}
   \begin{scope}[shift={(12,-28)}]
   \starV{cyan}{(0,17)}{6}{0}
   \starVI{cyan}{(22,17)}{6}{0}
   \starn{cyan}{9}{(22,0)}{8}{3}{0}
   \draw[gray] (22,0)circle(8) (22,0)circle(3);
   \moon{cyan}{(0,0)}{8}{(4,2)}{7}
   \draw[gray] (0,0)circle(8) (4,2)circle(7);
   \end{scope}
   \end{tikzpicture}
}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


% --------------------------------------------------------------------------
\chapter{Flags}\label{FLAGS}
% --------------------------------------------------------------------------

\section{Country Flags}
% ------------------------

\flagsdefault[width=18mm,length=30mm,stretch=1]

\show{Afghanistan}{AF}
\show{Albania}{AL}
\show{Algeria}{DZ}
\show{Andorra}{AD}
\show{Angola}{AO}
\show{Antigua \& Barbuda}{AG}
\show{Argentina}{AR}
\show{Armenia}{AM}
\show{Australia}{AU}
\show{Austria}{AT}
\show{Azerbaijan}{AZ}
\show{Bahamas}{BS}
\show{Bahrein}{BH}
\show{Bangladesh}{BD}
\show{Barbados}{BB}
\show{Belarus}{BY}
\show{Belgium}{BE}
\show{Belize}{BZ}
\show{Benin}{BJ}
\show{Bhutan}{BT}
\show{Bolivia}{BO}
\show{Bosnia \& Herzogovina}{BA}
\show{Botswana}{BW}
\show{Brazil}{BR}
\show{Brunei}{BN}
\show{Bulgaria}{BG}
\show{Burkina Faso}{BF}
\show{Burundi}{BI}
\show{Cambodia}{KH}
\show{Cameroon}{CM}
\show{Canada}{CA}
\show{Cape Verde}{CV}
\show{Central African Rep.}{CF}
\show{Chad}{TD}
\show{Chile}{CL}
\show{China}{CN}
\show{Colombia}{CO}
\show{Comoros}{KM}
\show{Congo, Democratic Rep.}{CD}
\show{Congo, Republic}{CG}
\show{Costa Rica}{CR}
\show{Cote d'Ivoire}{CI}
\show{Croatia}{HR}
\show{Cuba}{CU}
\show{Cyprus}{CY}
\show{Czech Republic}{CZ}
\show{Denmark}{DK}
\show{Djibouti}{DJ}
\show{Dominica}{DM}
\show{Dominican Republic}{DO}
\show{Ecuador}{EC}
\show{Egypt}{EG}
\show{EL Salvador}{SV}
\show{Equatorial Guinea}{GQ}
\show{Eritrea}{ER}
\show{Estonia}{EE}
\show{Ethiopia}{ET}
\show{Fiji}{FJ}
\show{Finnland}{FI}
\show{France}{FR}
\show{Gabon}{GA}
\show{Gambia}{GM}
\show{Georgia}{GE}
\show{Germany}{DE}
\show{Ghana}{GH}
\show{Great Britain}{GB}
\show{Greece}{GR}
\show{Grenada}{GD}
\show{Guatemala}{GT}
\show{Guinea}{GN}
\show{Guinea Bissau}{GW}
\show{Guyana}{GY}
\show{Haiti}{HT}
\show{Honduras}{HN}
\show{Hungary}{HU}
\show{Iceland}{IS}
\show{India}{IN}
\show{Indonesia}{ID}
\show{Iran}{IR}
\show{Iraq}{IQ}
\show{Ireland}{IE}
\show{Israel}{IL}
\show{Italy}{IT}
\show{Jamaica}{JM}
\show{Japan}{JP}
\show{Jordan}{JO}
\show{Kazakhstan}{KZ}
\show{Kenya}{KE}
\show{Kiribati}{KI}
\show{Kuwait}{KW}
\show{Kyrgystan}{KG}
\show{Laos}{LA}
\show{Latvia}{LV}
\show{Lebanon}{LB}
\show{Lesotho}{LS}
\show{Liberia}{LR}
\show{Libya}{LY}
\show{Liechtenstein}{LI}
\show{Lithuania}{LT}
\show{Luxembourg}{LU}
\show{Madagaskar}{mg}
\show{Malawi}{MW}
\show{Malaysia}{MY}
\show{Maledives}{MV}
\show{Mali}{ML}
\show{Malta}{MT}
\show{Marshall Islands}{MH}
\show{Mauritania}{MR}
\show{Mauritius}{MU}
\show{Mexico}{MX}
\show{Micronesia}{FM}
\show{Moldova}{MD}
\show{Mongolia}{MN}
\show{Montenegro}{ME}
\show{Morocco}{MA}
\show{Mozambique}{MZ}
\show{Myanmar}{MM}
\show{Namibia}{NA}
\show{Nauru}{NR}
\show{Nepal}{NP}
\show{Netherlands}{NL}
\show{New Zealsnd}{NZ}
\show{Nicaragua}{NI}
\show{Niger}{NE}
\show{Nigeria}{NG}
\show{North Korea}{KP}
\show{North Macedonia}{MK}
\show{Norway}{NO}
\show{Oman}{OM}
\show{Pakistan}{PK}
\show{Palau}{PW}
\show{Panama}{PA}
\show{Papua New Guinea}{PG}
\show{Paraguay}{PY}
\show{Peru}{PE}
\show{Philippines}{PH}
\show{Poland}{PL}
\show{Portugal}{pt}
\show{Quatar}{QA}
\show{Romania}{RO}
\show{Russia}{RU}
\show{Rwanda}{RW}
\show{St. Kitts \& Nevis}{KN}
\show{St. Lucia}{LC}
\show{St. Vincent}{VC}
\show{Samoa}{WS}
\show{San Marino}{SM}
\show{Sao Tome \& Principe}{ST}
\show{Saudi Arabia}{SA}
\show{Senegal}{SN}
\show{Serbia}{RS}
\show{Seychelles}{SC}
\show{Sierra Leone}{SL}
\show{Singapore}{SG}
\show{Slovakia}{SK}
\show{Slovenia}{SI}
\show{Solomon Islands}{SB}
\show{Somalia}{SO}
\show{South Africa}{ZA}
\show{South Korea}{KR}
\show{South Sudan}{SS}
\show{Spain}{ES}
\show{Sri Lanka}{LK}
\show{Sudan}{SD}
\show{Suriname}{SR}
\show{Swaziland}{SZ}
\show{Sweden}{SE}
\show{Switzerland}{CH}
\show{Syria}{SY}
\show{Taiwan}{TW}
\show{Tajikistan}{TJ}
\show{Tanzania}{TZ}
\show{Thailand}{TH}
\show{Togo}{TG}
\show{Tonga}{TO}
\show{Trinidad \& Tobago}{TT}
\show{Tunisia}{TN}
\show{Turkey}{TR}
\show{Turkmenistan}{TM}
\show{Tuvalu}{TV}
\show{Uganda}{UG}
\show{Ukraine}{UA}
\show{United Arab Emirates}{AE}
\show{United States}{US}
\show{Uruguay}{UY}
\show{Uzbekistan}{UZ}
\show{Vanuatu}{VU}
\show{Vatican}{VA}
\show{Venezuela}{VE}
\show{Viet Nam}{VN}
\show{Yemen}{YE}
\show{Zambia}{ZM}
\show{Zimbabwe}{ZW}

\section{Other Flags}
% ----------------------

\zaehler0
\show{European Union}{EU}
\show{United Nations}{UNO}
\show{Red Cross}{RedCross}
\show{Olympics}{Olympics}
\show{Jolly Roger}{JollyRoger}
\show{Rainbow fag}{Rainbow}

% --------------------------------------------------------------------------
% Links
% --------------------------------------------------------------------------
{
\raggedright
\def\web#1{{\color{emphcolor}\texttt{#1}}: }
\def\txt#1{#1}
\def\bibname{Links}
% \addcontentsline{toc}{chapter}{\bibname}

\begin{thebibliography}{88}
% ---------------------------------------------------------------------------
\bibitem{VEXILLAMUNDI}
\web{http://www.vexilla-mundi.com}
\txt{Comprehensive website with flags of all nations including construction
     sheets, historical flags, flags of many cities and regions.}
% ---------------------------------------------------------------------------
\bibitem{FOTW}
\web{https://www.fotw.info}
\txt{Website of the FOTW (``Flags Of The World''), vexillological association
 and internet resource; many background informations about flags and vexillology.}
% ---------------------------------------------------------------------------
\bibitem{WELTFLAGGEN}
\web{https://www.welt-flaggen.de}
\txt{Flags of and information about all countries of the world;
contains flag quizzes.}

% ---------------------------------------------------------------------------
\bibitem{NATIONALFLAGGEN}
\web{https://www.nationalflaggen.de}
\txt{Provides various images and animated gifs of all national flags.}
\end{thebibliography}
% ---------------------------------------------------------------------------
}
\end{document}