aboutsummaryrefslogtreecommitdiff
path: root/latex/tikzcards.tex
blob: 392f6f28af88db6e44094a284ca556a851c94c5b (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
% COMMANDS ZUM ZUSAMMENBAUEN DER KARTEN
% ---------------------------------------

% TikZ/PGF Settings für die Karten
\pgfmathsetmacro{\cardwidth}{6}
\pgfmathsetmacro{\cardheight}{9}
\pgfmathsetmacro{\imagewidth}{\cardwidth}
\pgfmathsetmacro{\imageheight}{0.75*\cardheight}
\pgfmathsetmacro{\stripwidth}{0.7}
\pgfmathsetmacro{\strippadding}{0.2}
\pgfmathsetmacro{\textpadding}{0.1}
\pgfmathsetmacro{\titley}{
    \cardheight - \strippadding - 1.5 * \textpadding - 0.5 * \stripwidth
}
\pgfmathsetmacro{\contentTextWidth}{
    (\cardwidth - 2* \strippadding - \stripwidth - 2* \textpadding - 0.3) * 1cm
}
\pgfmathsetmacro{\contentLeft}{2* \strippadding + \stripwidth + \textpadding}
\pgfmathsetmacro{\stripShortHeight}{1}
\pgfmathsetmacro{\contentBottom}{\stripShortHeight + \textpadding}
\pgfmathsetmacro{\leftStripLongHeight}{
    \cardheight - (3 * \strippadding) - \stripShortHeight
}

% Thresholds for the text in the left strip
\pgfmathsetmacro{\leftStripLongHeightNormal}{\leftStripLongHeight * 0.75}
\pgfmathsetmacro{\leftStripLongHeightSmall}{\leftStripLongHeight * 0.85}
\pgfmathsetmacro{\leftStripLongHeightFootnotesize}{\leftStripLongHeight * 0.95}
\pgfmathsetmacro{\leftStripLongHeightScriptsize}{\leftStripLongHeight * 1.05}

\pgfmathsetmacro{\leftStripTextXCoord}{\strippadding + 0.5 * \stripwidth}
\pgfmathsetmacro{\costXCoord}{\cardwidth - 0.5 * \stripwidth - \strippadding}


% Formen der einzelnen Kartenelemente/-bestandteile
\def\shapeCard{(0,0) rectangle (\cardwidth, \cardheight)}
\def\shapeLeftStripLong{
    (\strippadding, -\strippadding)
    rectangle
    (\strippadding + \stripwidth,
     \cardheight - \strippadding - \strippadding - \stripShortHeight)
}
\def\shapeLeftStripShort{
    (\strippadding, \cardheight - \strippadding - \stripShortHeight)
    rectangle
    (\strippadding + \stripwidth, \cardheight + \strippadding)
}
\def\shapeRightStripShortHigh{
    (\cardwidth - \stripwidth - \strippadding,
     \cardheight - \strippadding - \stripShortHeight)
    rectangle
    (\cardwidth - \strippadding, \cardheight + \strippadding)
}
\def\shapeRightStripShortLow{
    (\cardwidth - \stripwidth - \strippadding, -\strippadding)
    rectangle
    (\cardwidth - \strippadding, \stripShortHeight)
}
\def\shapeTitleArea{
    (2 * \strippadding + \stripwidth, \cardheight - \strippadding)
    rectangle
    (\cardwidth - 2 * \strippadding - \stripwidth, \cardheight - 2 * \stripwidth)
}


% macro to get the height of an node
% https://tex.stackexchange.com/questions/554237/how-can-i-get-the-height-of-a-tikz-node-and-store-it-in-a-length
\makeatletter % allow use of @
\NewDocumentCommand {\getnodedimen} {O{\nodewidth} O{\nodeheight} m} {
    \begin{pgfinterruptboundingbox}
        \begin{scope}[local bounding box=bb@temp]
            \node[inner sep=0pt, fit=(#3)] {};
        \end{scope}
        \path ($(bb@temp.north east)-(bb@temp.south west)$);
    \end{pgfinterruptboundingbox}
    \pgfgetlastxy{#1}{#2}
}
\makeatother % end use of @

% Stylings für die Elemente definieren
\tikzset{
    %   runde Ecken für die Karten
    cardcorners/.style={rounded corners=0.2cm},%
    %   runde Ecken für die "Fähnchen"
    elementcorners/.style={rounded corners=0.1cm},%
    strip/.style={elementcorners},%
    %   Bild für das Kartenmotiv
    cardimage/.style={%
        path picture={%
            \node[below=-1.5mm] at (0.5*\cardwidth,\cardheight) {%
                \includegraphics[width=\imagewidth cm]{#1}%
            };
        }%
    },%
}

% TikZ-Raster
\newcommand{\carddebug}{
    \draw [step=1,help lines] (0,0) grid (\cardwidth,\cardheight);
}

% Rahmen der Karte
\newcommand{\cardborder}{
    \draw[lightgray,cardcorners] \shapeCard;
}

% Hintergrund der Karte
\newcommand{\cardbackground}[1]{
    \draw[cardcorners, cardimage=#1] \shapeCard;
}

% Kategorie der Karte
% arg1: Background
% arg2: Type
% arg3: TypeIcon
% arg4: Text for left stripe
% arg5: Title
\newcommand{\cardtype}[5]{
    % First we fill the intersecting area
    % The \clip command does not allow options, therefore
    % we have to use a scope to set the even odd rule.
    \begin{scope}[even odd rule]
        % Define a clipping path. All paths outside shapeCard will
        % be cut because the even odd rule is set.
        \clip[cardcorners] \shapeCard;

        % Fill shapeLeftStripLong and shapeLeftStripShort.
        % Since the even odd rule is set, only the card will be filled.
        \fill[strip, #1] \shapeLeftStripLong;
        \fill[strip, #1] \shapeLeftStripShort;
    \end{scope}

    \node(leftStripTextInvisible) at (\leftStripTextXCoord, \leftStripLongHeight - \textpadding)
    [rotate=90, anchor=east, font=\normalsize, opacity=0] {
        \uppercase{#4 - #2}
    };

    \getnodedimen{leftStripTextInvisible}

    \node(leftStripText) at (\leftStripTextXCoord, \leftStripLongHeight - \textpadding)
    [rotate=90, anchor=east, font=\normalsize] {
        \color{white}

        \ifdimgreater{\leftStripLongHeightNormal cm}{\nodeheight}
        {\uppercase{#4 - #2}}
        {\ifdimgreater{\leftStripLongHeightSmall cm}{\nodeheight}
        {\small \uppercase{#4 - #2}}
        {\ifdimgreater{\leftStripLongHeightFootnotesize cm}{\nodeheight}
        {\footnotesize \uppercase{#4 - #2}}
        {\ifdimgreater{\leftStripLongHeightScriptsize cm}{\nodeheight}
        {\scriptsize \uppercase{#4 - #2}}
        {\tiny \uppercase{#4 - #2}}}}}
    };

    \node at (\leftStripTextXCoord, \cardheight - \strippadding - \strippadding - 0.37) {
        \color{white}#3
    };

    \cardtitle{#5}
}

% Known card types
\newcommand{\cardtypeUnitToken}[1]{
    \cardtype{tokenbg}{Unit}{\LARGE\sympawn}{TOKEN}{{\Large TOKEN} \\ #1}
}
\newcommand{\cardtypeUnit}[1]{\cardtype{unitbg}{Unit}{\LARGE\sympawn}{#1}{#1}}

\newcommand{\cardtypeSpellToken}[1]{
    \cardtype{tokenbg}{Spell}{\Large\faBolt}{TOKEN}{{\Large TOKEN} \\ #1}
}
\newcommand{\cardtypeSpell}[1]{\cardtype{spellbg}{Spell}{\Large\faBolt}{#1}{#1}}

\newcommand{\cardtypeIntention}[1]{
    \cardtype{intentionbg}{Intention}{\Large\faCrosshairs}{#1}{#1}
}

\newcommand{\cardtypeArtifactToken}[1]{
    \cardtype{tokenbg}{Artifact}{\LARGE\decoone}{TOKEN}{{\Large TOKEN} \\ #1}
}
\newcommand{\cardtypeArtifact}[1]{
    \cardtype{artifactbg}{Artifact}{\LARGE\decoone}{#1}{#1}
}

\newcommand{\cardtypeEquipmentToken}[1]{
    \cardtype{tokenbg}{Equipment}{\huge\dag}{TOKEN}{{\Large TOKEN} \\ #1}
}
\newcommand{\cardtypeEquipment}[1]{
    \cardtype{equipmentbg}{Equipment}{\huge\dag}{#1}{#1}
}

\newcommand{
    \cardtypePotion}[1]{\cardtype{equipmentbg}{Potion}{\Large\faFlask}{#1}{#1}
}
\newcommand{\cardtypePotionToken}[1]{
    \cardtype{equipmentbg}{Potion}{\Large\faFlask}{TOKEN}{\Large TOKEN}
}

% Titel der Karte
\newcommand{\cardtitle}[1]{
    \fill[elementcorners, titlebg, opacity=.85] \shapeTitleArea;
    \node[inner ysep=0, text width=3.75cm] at (0.5 * \cardwidth, \titley) {
        \begin{center}
            \color{white}\uppercase{\normalsize #1}
        \end{center}
    };
}

% Inhalt der Karte
\newcommand{\cardsplitcontent}[2]{
    % \begin{scope}[even odd rule]
        % \clip[cardcorners] \shapeCard;
    % \end{scope}

    % draw content node just to get its dimensions
    \node(content)[
        above right,
        minimum width=\cardwidth,
        text width=\contentTextWidth
    ] at (\contentLeft, \contentBottom) {
        \textit{\normalsize #1}
        \vrule width \textwidth height 2pt \\[-2pt]
        \vspace{0.2cm}
        {\normalsize #2}
    };

    % draw content background using dimensions of the content node
    \getnodedimen{content}
    \node[
        fill=contentbg,
        above right,
        elementcorners,
        minimum height=\nodeheight,
        minimum width=\nodewidth + 1
    ] at (\contentLeft - \textpadding, \contentBottom) {};

    % redraw content so it is on top of the background
    \node[
        above right,
        minimum width=\cardwidth,
        text width=\contentTextWidth
    ] at (\contentLeft, \contentBottom) {
        \textit{\normalsize #1}
        \vrule width \textwidth height 2pt \\[-2pt]
        \vspace{0.2cm}
        {\normalsize #2}
    };
}

% Inhalt der Karte
\newcommand{\cardcontent}[1]{
    % \begin{scope}[even odd rule]
        % \clip[cardcorners] \shapeCard;
    % \end{scope}
    \node(content)[
        above right,
        text width=\contentTextWidth
    ] at (\contentLeft, \contentBottom) {
        {\normalsize #1}
    };

    % draw content background using dimensions of the content node
    \getnodedimen{content}
    \node[
        fill=contentbg,
        above right,
        elementcorners,
        minimum height=\nodeheight,
        minimum width=\nodewidth + 1
    ] at (\contentLeft - \textpadding, \contentBottom) {};

    % redraw content so it is on top of the background
    \node[above right, text width=\contentTextWidth] at (\contentLeft, \contentBottom) {
        {\normalsize #1}
    };
}

% Buying cost
\newcommand{\cardbuycost}[1]{
    \begin{scope}[even odd rule]
        \clip[cardcorners] \shapeCard;
        \fill[strip, pricebg] \shapeRightStripShortHigh;
    \end{scope}
    \node at (\costXCoord, \titley - \textpadding) {\color{black}#1};
}

% Playing cost
\newcommand{\cardplaycost}[1]{
    \begin{scope}[even odd rule]
        \clip[cardcorners] \shapeCard;
        \fill[strip, playbg] \shapeRightStripShortLow;
    \end{scope}
    \node at (\costXCoord, \strippadding + \strippadding) {\color{black}#1};
}

% Module containing the card
\newcommand{\cardmodule}[1]{
    \node[rotate=90, right] at
    (\strippadding + 0.5 * \stripwidth, \textpadding)
    {\color{black}#1};
}