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