New puzzle! Or rather, new-ish, because this one has been lying around
[sgt/puzzles] / icons / Makefile
1 # Makefile for Puzzles icons.
2
3 PUZZLES = blackbox bridges cube dominosa fifteen filling flip galaxies guess \
4 inertia keen lightup loopy magnets map mines net netslide pattern \
5 pearl pegs range rect samegame signpost singles sixteen slant solo \
6 tents towers twiddle unequal untangle
7
8 BASE = $(patsubst %,%-base.png,$(PUZZLES))
9 WEB = $(patsubst %,%-web.png,$(PUZZLES))
10
11 IBASE = $(patsubst %,%-ibase.png,$(PUZZLES))
12 IBASE4 = $(patsubst %,%-ibase4.png,$(PUZZLES))
13 P48D24 = $(patsubst %,%-48d24.png,$(PUZZLES))
14 P48D8 = $(patsubst %,%-48d8.png,$(PUZZLES))
15 P48D4 = $(patsubst %,%-48d4.png,$(PUZZLES))
16 P32D24 = $(patsubst %,%-32d24.png,$(PUZZLES))
17 P32D8 = $(patsubst %,%-32d8.png,$(PUZZLES))
18 P32D4 = $(patsubst %,%-32d4.png,$(PUZZLES))
19 P16D24 = $(patsubst %,%-16d24.png,$(PUZZLES))
20 P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES))
21 P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES))
22 ICONS = $(patsubst %,%.ico,$(PUZZLES))
23 CICONS = $(patsubst %,%-icon.c,$(PUZZLES))
24 RC = $(patsubst %,%.rc,$(PUZZLES))
25
26 BIN = ../
27 PIC = ./
28
29 base: $(BASE)
30 web: $(WEB)
31 pngicons: $(P48D24) $(P32D24) $(P16D24)
32 winicons: $(ICONS) $(RC)
33 gtkicons: $(CICONS)
34 all: base web pngicons winicons gtkicons
35
36 # Build the base puzzle screenshots from which all the other images
37 # are derived. Some of them involve showing a move animation
38 # part-way through.
39 fifteen-base.png : override REDO=0.3
40 flip-base.png : override REDO=0.3
41 netslide-base.png : override REDO=0.3
42 sixteen-base.png : override REDO=0.3
43 twiddle-base.png : override REDO=0.3
44 $(BASE): %-base.png: $(BIN)% $(PIC)%.sav
45 $(PIC)screenshot.sh $(BIN)$* $(PIC)$*.sav $@ $(REDO)
46
47 # Build the screenshots for the web, by scaling the original base
48 # images to a uniform size.
49 $(WEB): %-web.png: %-base.png
50 $(PIC)square.pl 150 5 $^ $@
51
52 # Build the base _icon_ images, by careful cropping of the base
53 # images: icons are very small so it's often necessary to zoom in
54 # on a smaller portion of the screenshot.
55 blackbox-ibase.png : override CROP=352x352 144x144+0+208
56 bridges-ibase.png : override CROP=264x264 107x107+157+157
57 dominosa-ibase.png : override CROP=304x272 152x152+152+0
58 fifteen-ibase.png : override CROP=240x240 120x120+0+120
59 filling-ibase.png : override CROP=256x256 133x133+14+78
60 flip-ibase.png : override CROP=288x288 145x145+120+72
61 galaxies-ibase.png : override CROP=288x288 165x165+0+0
62 guess-ibase.png : override CROP=263x420 178x178+75+17
63 inertia-ibase.png : override CROP=321x321 128x128+193+0
64 keen-ibase.png : override CROP=288x288 96x96+24+120
65 lightup-ibase.png : override CROP=256x256 112x112+144+0
66 loopy-ibase.png : override CROP=257x257 113x113+0+0
67 magnets-ibase.png : override CROP=264x232 96x96+36+100
68 mines-ibase.png : override CROP=240x240 110x110+130+130
69 net-ibase.png : override CROP=193x193 113x113+0+80
70 netslide-ibase.png : override CROP=289x289 144x144+0+0
71 pattern-ibase.png : override CROP=384x384 223x223+0+0
72 pearl-ibase.png : override CROP=216x216 94x94+108+15
73 pegs-ibase.png : override CROP=263x263 147x147+116+0
74 range-ibase.png : override CROP=256x256 98x98+111+15
75 rect-ibase.png : override CROP=205x205 115x115+90+0
76 signpost-ibase.png : override CROP=240x240 98x98+23+23
77 singles-ibase.png : override CROP=224x224 98x98+15+15
78 sixteen-ibase.png : override CROP=288x288 144x144+144+144
79 slant-ibase.png : override CROP=321x321 160x160+160+160
80 solo-ibase.png : override CROP=481x481 145x145+24+24
81 tents-ibase.png : override CROP=320x320 165x165+142+0
82 towers-ibase.png : override CROP=300x300 102x102+151+6
83 twiddle-ibase.png : override CROP=192x192 102x102+69+21
84 unequal-ibase.png : override CROP=208x208 104x104+104+104
85 untangle-ibase.png : override CROP=320x320 164x164+3+116
86 $(IBASE): %-ibase.png: %-base.png
87 $(PIC)crop.sh $^ $@ $(CROP)
88
89 # Convert the full-size icon images to 4-bit colour, because that
90 # seems to work better than reducing it in 24 bits and then
91 # dithering.
92 $(IBASE4): %-ibase4.png: %-ibase.png
93 convert -colors 16 +dither -map $(PIC)win16pal.xpm $^ $@
94
95 # Build the 24-bit PNGs for the icons, at three sizes.
96 $(P48D24): %-48d24.png: %-ibase.png
97 $(PIC)square.pl 48 4 $^ $@
98 $(P32D24): %-32d24.png: %-ibase.png
99 $(PIC)square.pl 32 2 $^ $@
100 $(P16D24): %-16d24.png: %-ibase.png
101 $(PIC)square.pl 16 1 $^ $@
102
103 # The 8-bit icon PNGs are just custom-paletted quantisations of the
104 # 24-bit ones.
105 $(P48D8) $(P32D8) $(P16D8): %d8.png: %d24.png
106 convert -colors 256 $^ $@
107
108 # But the depth-4 images work better if we re-shrink from the
109 # ibase4 versions of the images, and then normalise the colours
110 # again afterwards. (They're still not very good, but my hope is
111 # that on most modern Windows machines this won't matter too
112 # much...)
113 $(P48D4): %-48d4.png: %-ibase4.png
114 $(PIC)square.pl 48 1 $^ $@-tmp2.png
115 convert -colors 16 -map $(PIC)win16pal.xpm $@-tmp2.png $@
116 rm -f $@-tmp2.png
117 $(P32D4): %-32d4.png: %-ibase.png
118 $(PIC)square.pl 32 1 $^ $@-tmp2.png
119 convert -colors 16 -map $(PIC)win16pal.xpm $@-tmp2.png $@
120 rm -f $@-tmp2.png
121 $(P16D4): %-16d4.png: %-ibase.png
122 $(PIC)square.pl 16 1 $^ $@-tmp2.png
123 convert -colors 16 -map $(PIC)win16pal.xpm $@-tmp2.png $@
124 rm -f $@-tmp2.png
125
126 # Build the actual Windows icons themselves, by feeding all those
127 # PNGs to my icon builder script.
128 $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \
129 %-32d24.png %-32d8.png %-32d4.png \
130 %-16d24.png %-16d8.png %-16d4.png
131 $(PIC)icon.pl -24 $*-48d24.png $*-32d24.png $*-16d24.png \
132 -8 $*-48d8.png $*-32d8.png $*-16d8.png \
133 -4 $*-48d4.png $*-32d4.png $*-16d4.png > $@
134
135 # Build the .RC files which bind the icons into the applications.
136 $(RC): %.rc:
137 echo '#include "puzzles.rc2"' > $@
138 echo '200 ICON "$*.ico"' >> $@
139
140 # Build the GTK icon source files.
141 $(CICONS): %-icon.c: %-16d24.png %-32d24.png %-48d24.png
142 $(PIC)cicon.pl $^ > $@
143
144 clean:
145 rm -f *.png *.ico *.rc *-icon.c