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