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