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