1#!/bin/bash
2#
3# program to create the icons
4# uses imagemagick
5#
6# 17. May 2004
7# Diether Knof <dknof@gmx.de>
8
9scaling=80
10
11INFO_GROUPS=true
12INFO_FILES=true
13
14if [ ! -e ../cards/club_queen.png ]; then
15  echo "could not find '../cards/club_queen.png' -- wrong directory?"
16  exit 1
17fi
18PATH=$PATH:../../../bin/
19
20# get the width and the height of the cards
21#width=`xpmtoppm ../cards/club_queen.png | pnmfile | awk '{ print $4 }'`
22#height=`xpmtoppm ../cards/club_queen.png | pnmfile | awk '{ print $6 }'`
23width=$(identify -format "%w" ../cards/club_queen.png)
24height=$(identify -format "%h" ../cards/club_queen.png)
25height_half=$(( ${height} / 2 ))
26
27overlap_width=$(( ${width} / 4 ))
28
29FILE_PIXEL=$(tempfile -p pixel. -s .png)
30FILE_OVERLAP=$(tempfile -p overlap. -s .png)
31FILE_OVERLAP_TMP=$(tempfile -p overlap_tmp. -s .png)
32
33test ${INFO_GROUPS} && echo "creating icons"
34
35overlap() {
36  convert ${FILE_PIXEL} -resize $(( ${width} + ($# - 1) * ${overlap_width} ))x${height_half}\! ${FILE_OVERLAP}
37
38  for (( i = 0; $# != 0 ; i++ )); do
39    composite -compose src-over -geometry +$(( $i * ${overlap_width} ))+0 ../cards/$1 ${FILE_OVERLAP} ${FILE_OVERLAP_TMP} \
40      && mv ${FILE_OVERLAP_TMP} ${FILE_OVERLAP}
41    shift
42  done # for i
43
44  cat ${FILE_OVERLAP}
45}
46
47echo -e "P4\n1 1\n" \
48| convert -transparent white - ${FILE_PIXEL}
49
50# re.png
51test ${INFO_FILES} && echo "  re.png"
52overlap club_queen.png \
53> re.png
54
55test ${INFO_FILES} && echo "  contra.png"
56thickness_x=$(( ${width} / 10 ))
57thickness_y=$(( ${height} / 10 ))
58convert -fill red -draw "polygon \
590,$(( $height_half - ${thickness_y} )) \
600,$(( $height_half )) \
61${thickness_x},$(( $height_half )) \
62$width,${thickness_y} \
63$width,0 \
64$(( $width - ${thickness_x} )),0 \
65" re.png t.png
66composite -compose In t.png re.png contra.png
67rm t.png
68
69# Soli
70test ${INFO_FILES} && echo "  solo.jack.png"
71overlap club_jack.png spade_jack.png heart_jack.png diamond_jack.png \
72> solo.jack.png
73test ${INFO_FILES} && echo "  solo.queen.png"
74overlap club_queen.png spade_queen.png heart_queen.png diamond_queen.png \
75> solo.queen.png
76test ${INFO_FILES} && echo "  solo.king.png"
77overlap club_king.png spade_king.png heart_king.png diamond_king.png \
78> solo.king.png
79test ${INFO_FILES} && echo "  solo.queen-jack.png"
80overlap club_queen.png spade_queen.png heart_jack.png diamond_jack.png \
81> solo.queen-jack.png
82test ${INFO_FILES} && echo "  solo.king-jack.png"
83overlap club_king.png spade_king.png heart_jack.png diamond_jack.png \
84> solo.king-jack.png
85test ${INFO_FILES} && echo "  solo.king-queen.png"
86overlap club_king.png spade_king.png heart_queen.png diamond_queen.png \
87> solo.king-queen.png
88test ${INFO_FILES} && echo "  solo.koehler.png"
89overlap club_king.png spade_king.png heart_queen.png diamond_jack.png \
90> solo.koehler.png
91
92# Idee: nur Farbsymbol
93test ${INFO_FILES} && echo "  solo.club.png"
94overlap spade_queen.png heart_jack.png club_ace.png club_king.png \
95> solo.club.png
96test ${INFO_FILES} && echo "  solo.spade.png"
97overlap club_queen.png heart_jack.png spade_ace.png spade_king.png \
98> solo.spade.png
99test ${INFO_FILES} && echo "  solo.heart.png"
100overlap club_queen.png diamond_jack.png heart_ace.png heart_king.png \
101> solo.heart.png
102test ${INFO_FILES} && echo "  solo.diamond.png"
103overlap club_queen.png heart_jack.png diamond_ace.png diamond_king.png \
104> solo.diamond.png
105
106test ${INFO_FILES} && echo "  solo.meatless.png"
107overlap club_ace.png spade_ace.png heart_ace.png diamond_ace.png \
108> solo.meatless.png
109
110# marriage
111# Idee: Hochzeitsringe
112test ${INFO_FILES} && echo "  marriage.png"
113overlap club_queen.png club_queen.png \
114> marriage.png
115test ${INFO_FILES} && echo "  marriage.foreign.png"
116overlap club_queen.png club_queen.png diamond_jack.png spade_ace.png \
117> marriage.foreign.png
118test ${INFO_FILES} && echo "  marriage.trump.png"
119overlap club_queen.png club_queen.png heart_jack.png diamond_ace.png \
120> marriage.trump.png
121# Idee: Hochzeitsringe + 3 Farbsymbole
122test ${INFO_FILES} && echo "  marriage.color.png"
123overlap club_queen.png club_queen.png heart_ace.png spade_ace.png \
124> marriage.color.png
125# Idee: Hochzeitsringe + Farbsymbol
126test ${INFO_FILES} && echo "  marriage.club.png"
127overlap club_queen.png club_queen.png club_ace.png club_ace.png \
128> marriage.club.png
129test ${INFO_FILES} && echo "  marriage.spade.png"
130overlap club_queen.png club_queen.png spade_ace.png spade_ace.png \
131> marriage.spade.png
132test ${INFO_FILES} && echo "  marriage.heart.png"
133overlap club_queen.png club_queen.png heart_ace.png heart_ace.png \
134> marriage.heart.png
135test ${INFO_FILES} && echo "  marriage.partner.png"
136overlap club_queen.png \
137> marriage.partner.png
138
139# genscher
140test ${INFO_FILES} && echo "  genscher.png"
141overlap diamond_king.png diamond_king.png \
142> genscher.png
143
144# poverty
145test ${INFO_FILES} && echo "  poverty.png"
146overlap heart_queen.png spade_jack.png diamond_ten.png \
147> poverty.png
148test ${INFO_FILES} && echo "  poverty.3.png"
149overlap heart_queen.png spade_jack.png diamond_ten.png \
150> poverty.3.png
151test ${INFO_FILES} && echo "  poverty.2.png"
152overlap heart_queen.png diamond_ten.png club_ace.png \
153> poverty.2.png
154test ${INFO_FILES} && echo "  poverty.1.png"
155overlap heart_queen.png club_ace.png heart_king.png \
156> poverty.1.png
157test ${INFO_FILES} && echo "  poverty.0.png"
158overlap club_ace.png heart_king.png spade_ten.png \
159> poverty.0.png
160test ${INFO_FILES} && echo "  poverty.partner.png"
161overlap club_queen.png \
162> poverty.partner.png
163
164# thrown nines
165test ${INFO_FILES} && echo "  thrown_nines.png"
166overlap club_nine.png spade_nine.png heart_nine.png diamond_nine.png \
167> thrown_nines.png
168
169# thrown kings
170test ${INFO_FILES} && echo "  thrown_kings.png"
171overlap club_king.png spade_king.png heart_king.png diamond_king.png \
172> thrown_kings.png
173
174# thrown nines and kings
175test ${INFO_FILES} && echo "  thrown_nines_and_kings.png"
176overlap club_king.png spade_king.png heart_nine.png diamond_nine.png \
177> thrown_nines_and_kings.png
178
179# thrown richness
180# Idee: Viele Münzen
181test ${INFO_FILES} && echo "  thrown_richness.png"
182overlap club_ten.png spade_ten.png heart_ten.png diamond_ten.png \
183> thrown_richness.png
184
185# fox highest trump
186test ${INFO_FILES} && echo "  fox_highest_trump.png"
187overlap diamond_ace.png diamond_ten.png diamond_king.png diamond_nine.png \
188> fox_highest_trump.png
189
190# swines
191# Idee: Schwein
192test ${INFO_FILES} && echo "  swines.club.png"
193overlap club_ace.png club_ace.png \
194> swines.club.png
195test ${INFO_FILES} && echo "  swines.spade.png"
196overlap spade_ace.png spade_ace.png \
197> swines.spade.png
198test ${INFO_FILES} && echo "  swines.heart.png"
199overlap heart_ace.png heart_ace.png \
200> swines.heart.png
201test ${INFO_FILES} && echo "  swines.diamond.png"
202overlap diamond_ace.png diamond_ace.png \
203> swines.diamond.png
204
205# hyperswines
206# Idee: besonderes Schwein
207test ${INFO_FILES} && echo "  hyperswines.club.png"
208overlap club_nine.png club_nine.png \
209> hyperswines.club.png
210test ${INFO_FILES} && echo "  hyperswines.spade.png"
211overlap spade_nine.png spade_nine.png \
212> hyperswines.spade.png
213test ${INFO_FILES} && echo "  hyperswines.heart.png"
214overlap heart_nine.png heart_nine.png \
215> hyperswines.heart.png
216test ${INFO_FILES} && echo "  hyperswines.diamond.png"
217overlap diamond_nine.png diamond_nine.png \
218> hyperswines.diamond.png
219# without nines
220test ${INFO_FILES} && echo "  hyperswines.king.club.png"
221overlap club_king.png club_king.png \
222> hyperswines.king.club.png
223test ${INFO_FILES} && echo "  hyperswines.king.spade.png"
224overlap spade_king.png spade_king.png \
225> hyperswines.king.spade.png
226test ${INFO_FILES} && echo "  hyperswines.king.heart.png"
227overlap heart_king.png heart_king.png \
228> hyperswines.king.heart.png
229test ${INFO_FILES} && echo "  hyperswines.king.diamond.png"
230overlap diamond_king.png diamond_king.png \
231> hyperswines.king.diamond.png
232
233# swines and hyperswines
234test ${INFO_FILES} && echo "  swines-hyperswines.club.png"
235overlap club_ace.png club_nine.png \
236> swines-hyperswines.club.png
237test ${INFO_FILES} && echo "  swines-hyperswines.spade.png"
238overlap spade_ace.png spade_nine.png \
239> swines-hyperswines.spade.png
240test ${INFO_FILES} && echo "  swines-hyperswines.heart.png"
241overlap heart_ace.png heart_nine.png \
242> swines-hyperswines.heart.png
243test ${INFO_FILES} && echo "  swines-hyperswines.diamond.png"
244overlap diamond_ace.png diamond_nine.png \
245> swines-hyperswines.diamond.png
246# without nines
247test ${INFO_FILES} && echo "  swines-hyperswines.king.club.png"
248overlap club_ace.png club_king.png \
249> swines-hyperswines.king.club.png
250test ${INFO_FILES} && echo "  swines-hyperswines.king.spade.png"
251overlap spade_ace.png spade_king.png \
252> swines-hyperswines.king.spade.png
253test ${INFO_FILES} && echo "  swines-hyperswines.king.heart.png"
254overlap heart_ace.png heart_king.png \
255> swines-hyperswines.king.heart.png
256test ${INFO_FILES} && echo "  swines-hyperswines.king.diamond.png"
257overlap diamond_ace.png diamond_king.png \
258> swines-hyperswines.king.diamond.png
259
260# dullen
261test ${INFO_FILES} && echo "  dullen.png"
262overlap heart_ten.png heart_ten.png \
263> dullen.png
264
265# specialpoints
266# Idee: Zwei Köpfe
267test ${INFO_FILES} && echo "  doppelkopf.png"
268overlap club_ace.png spade_ten.png diamond_ace.png heart_ten.png \
269> doppelkopf.png
270
271# no_*_reply
272for limit in 120 90 60 30 0; do
273  test ${INFO_FILES} && echo "  no_${limit}_reply.png"
274  scale=8
275  echo "%!PS-Adobe-3.0
276%%LanguageLevel: 2
277%%
278%%Title: no $limit reply
279%%For: Diether Knof
280%%CreationDate: 15-12-2006
281%%Creator: Diether Knof
282%%
283%%Orientation: Portrait
284%%BoundingBox: 0 0 $(($scale * $width)) $(($scale * $width / 2))
285%%Pages: 1
286%%
287%%EndComments
288
289%Groesse ~ 842x595
290$scale dup scale
291/breite $(($width)) def
292/hoehe $(($width / 2)) def
293
294%
295% change encoding to ISO8859-1  -  reiner@schildi.xnc.com
296%
297% <fontname> ISOfindfont => <font>
298%
299/ISOfindfont {
300dup 100 string cvs (ISO-) exch concatstrings cvn exch
301findfont dup maxlength dict begin
302{ 1 index /FID ne {def}{pop pop} ifelse } forall
303  /Encoding ISOLatin1Encoding def
304  currentdict
305  end definefont
306} def
307
308/Times-ItalicBold ISOfindfont
309setfont
310
311/Zentriere {
312  % Text
313  /Groesse exch def
314  /Text exch def
315  gsave
316  %    /StandardSymL ISOfindfont
317  ISOfindfont
318  Groesse scalefont
319  setfont
320  breite Text stringwidth pop sub 2 div
321  1 moveto
322  Text show
323  grestore
324} def
325
326%%Page: 1 1
327
328/Times-Bold ($limit) $(($width * 2 / 3)) Zentriere
329
330showpage
331
332quit"\
333> no_${limit}_reply.ps
334#convert -colors 3 -transparent white no_${limit}_reply.ps no_${limit}_reply.png
335convert -colors 2 -white-threshold 65000 -transparent white no_${limit}_reply.ps no_${limit}_reply.png
336#mogrify -transparent white no_${limit}_reply.png
337mogrify -resize ${width}x$(($width / 2)) no_${limit}_reply.png
338rm -f no_${limit}_reply.ps
339done
340
341# no_*
342  echo "%!PS-Adobe-3.0
343%%LanguageLevel: 2
344%%
345%%Title: stroke
346%%For: Diether Knof
347%%CreationDate: 15-12-2006
348%%Creator: Diether Knof
349%%
350%%Orientation: Portrait
351%%BoundingBox: 0 0 $(($scale * $width)) $(($scale * $width / 2))
352%%Pages: 1
353%%
354%%EndComments
355
356%Groesse ~ 842x595
357$scale $width mul 100 div dup scale
358/breite 100 def
359/hoehe 50 def
360
36110 setlinewidth
362
363%%Page: 1 1
364
365gsave
366/DeviceRGB setcolorspace
3671 0 0 setcolor
368newpath
3695 10 moveto
370breite 5 sub hoehe 10 sub lineto
371closepath
372stroke
373grestore
374
375showpage
376
377quit"\
378> stroke.ps
379convert -colors 2 -white-threshold 65000 -transparent white stroke.ps stroke.png
380#mogrify -transparent white stroke.png
381mogrify -resize ${width}x$(($width / 2)) stroke.png
382for limit in 120 90 60 30 0; do
383  test ${INFO_FILES} && echo "  no_${limit}"
384  composite stroke.png no_${limit}_reply.png no_${limit}.png
385done
386rm -f stroke.ps stroke.png
387
388test ${INFO_GROUPS} && echo "scaling all icons"
389# scale all icons
390for f in re.png contra.png solo*.png marriage*.png genscher.png poverty*.png thrown_nines.png thrown_kings.png thrown_nines_and_kings.png fox_highest_trump.png swines.*.png hyperswines.*.png swines-hyperswines.*.png no_*.png
391do
392  #convert -scale $(( $width * $scaling / 100 ))x$(( $height * $scaling / 100 )) \
393  test ${INFO_FILES} && echo "  $f"
394  mogrify -resize $scalingx$scaling% $f
395done
396
397
398rm ${FILE_PIXEL}
399rm ${FILE_OVERLAP}
400
401
402test ${INFO_GROUPS} && echo "sharpen all icons"
403# sharpen and minimize
404for f in *.png; do \
405  test ${INFO_FILES} && echo "  $f"
406  mogrify -sharpen 1 $f
407  pngcrushmin $f
408done
409
410