diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/worldflags/worldflags.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/worldflags/worldflags.sty | 133 |
1 files changed, 77 insertions, 56 deletions
diff --git a/Master/texmf-dist/tex/latex/worldflags/worldflags.sty b/Master/texmf-dist/tex/latex/worldflags/worldflags.sty index fa3df66e954..2a6df521141 100644 --- a/Master/texmf-dist/tex/latex/worldflags/worldflags.sty +++ b/Master/texmf-dist/tex/latex/worldflags/worldflags.sty @@ -1,6 +1,6 @@ % ============================================================================= % worldflags.sty - Flags of the World with TikZ -% (c) Wilhelm Haager 2021-04-25 +% (c) Wilhelm Haager 2021-04-30 % ============================================================================= \RequirePackage{ifthen} \RequirePackage{tikz} @@ -27,14 +27,14 @@ % ---------------------------------------------------------------------------- % 2 horizontal stripes % ---------------------------------------------------------------------------- -\def\hstripesII#1#2{% 3 horizontal stripes +\def\wf@hstripesII#1#2{% 3 horizontal stripes \fill [#1] (0,1/2) rectangle (\flaglength,1); \fill [#2] (0,0) rectangle (\flaglength,1/2);} % ---------------------------------------------------------------------------- % 3 horizontal stripes % ---------------------------------------------------------------------------- -\def\hstripesIII#1#2#3{% 3 horizontal stripes +\def\wf@hstripesIII#1#2#3{% 3 horizontal stripes \fill [#1] (0,2/3) rectangle (\flaglength,1); \fill [#2] (0,1/3) rectangle (\flaglength,2/3); \fill [#3] (0,0) rectangle (\flaglength,1/3);} @@ -42,7 +42,7 @@ % ---------------------------------------------------------------------------- % 4 horizontal stripes % ---------------------------------------------------------------------------- -\def\hstripesIV#1#2#3#4{% +\def\wf@hstripesIV#1#2#3#4{% \fill [#1] (0,3/4) rectangle (\flaglength,1); \fill [#2] (0,1/2) rectangle (\flaglength,3/4); \fill [#3] (0,1/4) rectangle (\flaglength,1/2); @@ -51,7 +51,7 @@ % ---------------------------------------------------------------------------- % 5 horizontal stripes % ---------------------------------------------------------------------------- -\def\hstripesV#1#2#3#4#5{% +\def\wf@hstripesV#1#2#3#4#5{% \fill [#1] (0,4/5) rectangle (\flaglength,1); \fill [#2] (0,3/5) rectangle (\flaglength,4/5); \fill [#3] (0,2/5) rectangle (\flaglength,3/5); @@ -61,7 +61,7 @@ % ---------------------------------------------------------------------------- % 6 horizontal stripes % ---------------------------------------------------------------------------- -\def\hstripesVI#1#2#3#4#5#6{% +\def\wf@hstripesVI#1#2#3#4#5#6{% \fill [#1] (0,5/6) rectangle (\flaglength,1); \fill [#2] (0,4/6) rectangle (\flaglength,5/6); \fill [#3] (0,3/6) rectangle (\flaglength,4/6); @@ -72,14 +72,14 @@ % ---------------------------------------------------------------------------- % 2 vertical stripes % ---------------------------------------------------------------------------- -\def\vstripesII#1#2{% 2 vertical stripes +\def\wf@vstripesII#1#2{% 2 vertical stripes \fill [#1] (0,0) rectangle (0.5\flaglength,1); \fill [#2] (0.5\flaglength,0) rectangle (\flaglength,1);} % ---------------------------------------------------------------------------- % 3 vertical stripes % ---------------------------------------------------------------------------- -\def\vstripesIII#1#2#3{% 3 vertical stripes +\def\wf@vstripesIII#1#2#3{% 3 vertical stripes \fill [#1] (0,0) rectangle (\flaglength/3,1); \fill [#2] (\flaglength/3,0) rectangle (2\flaglength/3,1); \fill [#3] (2\flaglength/3,0) rectangle (\flaglength,1);} @@ -88,7 +88,7 @@ % Vertical bar (width relative to flagWIDTH) % ---------------------------------------------------------------------------- % #1...color, #2...position, #3...width -\def\vbar#1#2#3{% +\def\wf@vbar#1#2#3{% \fill [#1] (#2,0) ++(-#3/2,0) rectangle ++(#3,1);} @@ -96,14 +96,14 @@ % Horizontal bar (width relative to flagwidth) % ---------------------------------------------------------------------------- % #1...color, #2...position, #3...width -\def\hbar#1#2#3{% +\def\wf@hbar#1#2#3{% \fill [#1] (0,#2) ++(0,-#3/2) rectangle ++(\flaglength,#3);} % ---------------------------------------------------------------------------- % Cevron; #1...color, #2...width % ---------------------------------------------------------------------------- -\def\chevron#1#2{% +\def\wf@chevron#1#2{% \fill [#1] (0,0)--(0,1)--(#2,0.5)--cycle;} % ---------------------------------------------------------------------------- @@ -111,7 +111,7 @@ % ---------------------------------------------------------------------------- % #1...color, #2...points, #3...coordinate, #4...outer radius, % #5...inner radius, #6...angle -\def\starn#1#2#3#4#5#6{% +\def\wf@starn#1#2#3#4#5#6{% \begin{scope}[shift={#3},rotate=#6] \fill [#1] (90:#4) foreach \n in {1,...,#2} {--(90-180/#2+\n*360/#2:#5)--(90+\n*360/#2:#4)}--cycle; @@ -121,20 +121,26 @@ % 5-pointed-star % ---------------------------------------------------------------------------- % #1...color, #2...coordinate, #3...outer radius, #4...angle -\def\starV#1#2#3#4{\starn{#1}{5}{#2}{#3}{0.381966*#3}{#4}} +\def\wf@starV#1#2#3#4{\starn{#1}{5}{#2}{#3}{0.381966*#3}{#4}} % ---------------------------------------------------------------------------- % 6-pointed-star % ---------------------------------------------------------------------------- % #1...color, #2...coordinate, #3...outer radius, #4...angle -\def\starVI#1#2#3#4{\starn{#1}{6}{#2}{#3}{0.57735*#3}{#4}} +\def\wf@starVI#1#2#3#4{\starn{#1}{6}{#2}{#3}{0.57735*#3}{#4}} + +% ---------------------------------------------------------------------------- +% Background; #1...color +% ---------------------------------------------------------------------------- +\def\wf@background#1{% + \fill [#1] (0,0) rectangle (\flaglength,\flagwidth);} % ---------------------------------------------------------------------------- % Moon % ---------------------------------------------------------------------------- % #1...color, #2...outer coordinates, #3...outer radius, % #4 inner coordinates #5...inner radius -\def\moon#1#2#3#4#5{% +\def\wf@moon#1#2#3#4#5{% \begin{scope} \clip #2 circle (#3); \fill [even odd rule,#1] #2 circle (1.01*#3) #4 circle (#5); @@ -143,31 +149,31 @@ % ---------------------------------------------------------------------------- % Natural aspect-ratio of a flag (for internal use) % ---------------------------------------------------------------------------- -\def\AspectRatio#1#2{% - \ifdim\flaglength=0pt\flaglength\flagwidth\divide\flaglength by #1\multiply\flaglength by #2\fi - \ifdim\flagwidth=0pt\flagwidth\flaglength\divide\flagwidth by #2\multiply\flagwidth by #1\fi - \newdimen\sh\sh=-\flagwidth\divide\sh by #1\multiply\sh by #2\advance\sh by\flaglength\sh=\flagstretch\sh - \pgfmathparse{(\flaglength/\flagwidth*#1/#2-1)*\flagstretch+1} - \edef\StretchFactor{\pgfmathresult} - } +\def\wf@aspectratio#1{% + \ifx\flagstretch\undefined\def\flagstretch{0}\fi + \ifx\flaglength\undefined\newdimen\flaglength\flaglength0pt\fi + \ifdim\flaglength=0pt\pgfmathparse{\flagwidth/(#1)}\pgfmathsetlength{\flaglength}{\pgfmathresult}\fi + \ifdim\flagwidth=0pt\pgfmathparse{\flaglength*(#1)}\pgfmathsetlength{\flagwidth}{\pgfmathresult}\fi + \pgfmathparse{(\flaglength/\flagwidth*(#1)-1)*\flagstretch+1} + \edef\stretchfactor{\pgfmathresult}} % ---------------------------------------------------------------------------- -% FrameCode and GridCode +% wf@framecode and wf@gridcode % ---------------------------------------------------------------------------- -\def\FrameCode{ +\def\wf@framecode{\end{scope} \ifx\framecolor\undefined\global\def\framecolor{\fr@mecolor}\fi \ifx\flagframe\undefined\newdimen\flagframe\global\flagframe\fl@gframe\fi \ifdim\flagframe>0pt\draw - [\framecolor,line width=\flagframe] (0,0) rectangle (\flaglength,\flagwidth);\fi} - -\def\GridCode{\ifgrid + [\framecolor,line width=\flagframe] (0,0) rectangle (\flaglength,\flagwidth);\fi + \begin{scope}} +\def\wf@gridcode{\ifgrid \begin{scope}[x=1mm,y=1mm] - \pgfmathparse{\flaglength*0.351} + \pgfmathparse{\flaglength*0.351462} \def\n{\pgfmathresult} \foreach \x in {0,1,...,\n} \draw [line width=0.1pt,gridcolor!20] (\x,0)--++(0,\flagwidth); \foreach \x in {0,5,...,\n} \draw [line width=0.25pt,gridcolor!60] (\x,0)--++(0,\flagwidth); \foreach \x in {0,10,...,\n} \draw [line width=0.5pt,gridcolor] (\x,0)--++(0,\flagwidth); - \pgfmathparse{\flagwidth*0.351} + \pgfmathparse{\flagwidth*0.351462} \def\n{\pgfmathresult} \foreach \x in {0,1,...,\n} \draw [line width=0.1pt,gridcolor!20] (0,\x)--++(\flaglength,0); \foreach \x in {0,5,...,\n} \draw [line width=0.25pt,gridcolor!60] (0,\x)--++(\flaglength,0); @@ -176,13 +182,39 @@ \fi} % ---------------------------------------------------------------------------- -% Begin and end of flag description (just initiates and ends zwo scopes) +% Environment flagdescription % ---------------------------------------------------------------------------- -\def\BeginFlagDescription#1#2{% - \AspectRatio{#1}{#2} +\newenvironment{flagdescription}[1]{% +% \begingroup + \def\makeifgrid{\newif\ifgrid\if@rid\gridtrue\else\gridfalse\fi} + \ifx\flagwidth\undefined\newdimen\flagwidth\flagwidth\fl@gwidth\fi + \ifx\ifgrid\undefined\makeifgrid\fi + \let\hstripesII=\wf@hstripesII + \let\hstripesIII=\wf@hstripesIII + \let\hstripesIV=\wf@hstripesIV + \let\hstripesV=\wf@hstripesV + \let\hstripesVI=\wf@hstripesVI + \let\vstripesII=\wf@vstripesII + \let\vstripesIII=\wf@vstripesIII + \let\starn=\wf@starn + \let\starV=\wf@starV + \let\starVI=\wf@starVI + \let\moon=\wf@moon + \let\unionjack=\wf@unionjack + \let\hbar=\wf@hbar + \let\vbar=\wf@vbar + \let\chevron=\wf@chevron + \let\framecode=\wf@framecode + \let\gridcode=\wf@gridcode + \let\background=\wf@background + \wf@aspectratio{#1} + \ifx\viewangle\undefined\def\viewangle{0}\fi + \ifx\hangangle\undefined\def\hangangle{0}\fi \begin{scope}[x=\flagwidth,y=\flagwidth,cm={cos(\viewangle)*cos(\hangangle), -sin(\hangangle),0,1,(0,0)}] \begin{scope}[shift={(-0.5\flaglength,-0.5\flagwidth)}] + \begin{scope} % inner scope for clipping + \clip (0,0) rectangle (\flaglength,\flagwidth); \coordinate (-0) at (0.5\flaglength,0.5\flagwidth); \coordinate (-nw) at (0,\flagwidth); \coordinate (-w) at (0,0.5\flagwidth); @@ -192,12 +224,23 @@ \coordinate (-ne) at (\flaglength,\flagwidth); \coordinate (-e) at (\flaglength,0.5\flagwidth); \coordinate (-se) at (\flaglength,0);} -\def\EndFlagDescription{\GridCode\end{scope}\end{scope}} +{\end{scope}\wf@gridcode\end{scope}\end{scope}%\endgroup + \global\let\flagwidth\undefined + \global\let\flaglength\undefined + \global\let\flagframe\undefined + \global\let\flagstretch\undefined + \global\let\framecolor\undefined + \global\let\ifemblem\undefined + \global\let\ifnoemblem\undefined + \global\let\ifgrid\undefined + \global\let\viewangle\undefined + \global\let\hangangle\undefined +} % ---------------------------------------------------------------------------- % Union Jack (neuer Versuch, 12.4.2021) % ---------------------------------------------------------------------------- -\def\UnionJack#1#2#3#4{% +\def\wf@unionjack#1#2#3#4{% \begin{scope}[cm={1,0,0,1,(#1,#2)}] \newdimen\b\b=#3\advance\b by -#1 \newdimen\h\h=#4\advance\h by -#2 @@ -273,16 +316,6 @@ \begin{tikzpicture} \input{worldflag_#2.tex} \end{tikzpicture}}{\relax} - \global\let\flagwidth\undefined - \global\let\flaglength\undefined - \global\let\flagframe\undefined - \global\let\flagstretch\undefined - \global\let\framecolor\undefined - \global\let\ifemblem\undefined - \global\let\ifnoemblem\undefined - \global\let\ifgrid\undefined - \global\let\viewangle\undefined - \global\let\hangangle\undefined } % ---------------------------------------------------------------------------- @@ -302,7 +335,6 @@ \tikzset{hang/.style={execute at begin scope={\def\hangangle{#1}}}} \tikzset{ worldflag/.pic={ - %\begin{scope} \ifx\flagwidth\undefined\newdimen\flagwidth\global\flagwidth=\fl@gwidth\fi \ifx\flaglength\undefined\newdimen\flaglength\global\flaglength=\fl@glength\fi \ifx\flagframe\undefined\newdimen\flagframe\global\flagframe=\fl@gframe\fi @@ -317,16 +349,5 @@ \ifx\viewangle\undefined\def\viewangle{\view@ngle}\fi \ifx\hangangle\undefined\def\hangangle{\hang@ngle}\fi \IfFileExists{worldflag_\country.tex}{\input{worldflag_\country.tex}}{\relax} - %\end{scope} - \global\let\flagwidth\undefined - \global\let\flaglength\undefined - \global\let\flagframe\undefined - \global\let\flagstretch\undefined - \global\let\framecolor\undefined - \global\let\ifemblem\undefined - \global\let\ifnoemblem\undefined - \global\let\ifgrid\undefined - \global\let\viewangle\undefined - \global\let\hangangle\undefined } } |