less magical makefile
[koperkapel.git] / koperkapel / images / Makefile
1 VPATH=../../sources/vector
2
3 TILE_DIRS=roach
4 TILE_SVGS=$(shell find $(patsubst %, $(VPATH)/%, $(TILE_DIRS)) -name "*.svg")
5 TILE_PNGS=$(patsubst $(VPATH)/%.svg, %.png, $(TILE_SVGS))
6
7 ROACH=$(filter roach/%, $(TILE_PNGS))
8 ROACH_32=$(patsubst roach/%, roach_32/%, $(ROACH))
9 ROACH_21=$(patsubst roach/%, roach_21/%, $(ROACH))
10 ROACH_QUARTET=$(patsubst roach/%, roach_quartet/%, $(ROACH))
11 ROACH_NONET=$(patsubst roach/%, roach_nonet/%, $(ROACH))
12
13 all: $(TILE_PNGS) $(ROACH_32) $(ROACH_21) $(ROACH_QUARTET) $(ROACH_NONET)
14
15 # Tile rules
16
17 define tile
18 $(1)/%.png: $(1)/%.svg
19         @mkdir -p `dirname $$@`
20         @inkscape -z -e $$@ -w 64 -h 64 $$<
21 endef
22
23 $(foreach tiledir,$(TILE_DIRS),$(eval $(call tile,$(tiledir))))
24
25 # Smaller roaches
26
27 roach_32/%.png: roach/%.svg
28         @mkdir -p `dirname $@`
29         @inkscape -z -e $@ -w 32 -h 32 $<
30
31 roach_21/%.png: roach/%.svg
32         @mkdir -p `dirname $@`
33         @inkscape -z -e $@ -w 21 -h 21 $<
34
35 # Roach quartet
36
37 roach_quartet/roach_%.png: $(foreach i, 1 2 3 4, roach_32/roach_$(i).png)
38         @mkdir -p roach_quartet
39         @montage $(foreach i, -1 0 1 2 , roach_32/roach_$$(( ( $(i) + $(patsubst roach_quartet/roach_%.png,%, $@) ) % 4 + 1 )).png) -geometry +0+0 -background none $@
40
41 roach_quartet/eyes_%.png: $(foreach i, 1 2 3 4, roach_32/eyes_$(i).png)
42         @mkdir -p roach_quartet
43         @montage $(foreach i, -1 0 1 2 , roach_32/eyes_$$(( ( $(i) + $(patsubst roach_quartet/eyes_%.png,%, $@) ) % 4 + 1 )).png) -geometry +0+0 -background none $@
44
45 # Roach nonet
46
47 roach_nonet/roach_%.png: $(foreach i, 1 2 3 4, roach_21/roach_$(i).png)
48         @mkdir -p roach_nonet
49         @montage $(foreach i, -1 0 1 2 3 4 5 6 7 , roach_21/roach_$$(( ( $(i) + $(patsubst roach_nonet/roach_%.png,%, $@) ) % 4 + 1 )).png) -geometry +0+0 -background none - | convert - -background none -gravity southeast -splice 1x1 $@
50
51 roach_nonet/eyes_%.png: $(foreach i, 1 2 3 4, roach_21/eyes_$(i).png)
52         @mkdir -p roach_nonet
53         @montage $(foreach i, -1 0 1 2 3 4 5 6 7 , roach_21/eyes_$$(( ( $(i) + $(patsubst roach_nonet/eyes_%.png,%, $@) ) % 4 + 1 )).png) -geometry +0+0 -background none - | convert - -background none -gravity southeast -splice 1x1 $@
54
55