default: afnog-map.png afnog-map.194x213.png
clean-temp:
	rm -f afnog-map-raw.png afnog-map-transparent.png
clean: clean-temp
	rm -f afnog-map.png afnog-map.194x213.png

afnog-map-raw.png: afnog-africa-map.fig
	fig2dev -L png afnog-africa-map.fig >${.TARGET}

# Convert the background from white to transparent.
#
# "-fill blue" sets the colour to be used by
# "-draw 'color x,y floodfill'".  We need to do the
# floodfill twice, once to fill the top half of the background,
# and once to fill the bottom half of the background.
# Next, "-transparent blue" converts the blue background
# to transparent.  For some reason, "-fill transparent"
# doesn't work, but "-fill blue" followed by "-transparent blue"
# does work.
# Finally, we convert to GIF and then back to PNG format
# to ensure that we get an indexed PNG.
afnog-map-transparent.png: afnog-map-raw.png
	convert -fill blue \
		-draw 'color 0,0 floodfill' \
		-draw 'color 0,640 floodfill' \
		-transparent blue \
		afnog-map-raw.png gif:- \
	| convert gif:- ${.TARGET}

afnog-map.png: afnog-map-transparent.png afnog-stamp-rotated.png
	composite -geometry +160+0 afnog-stamp-rotated.png \
		afnog-map-transparent.png gif:- \
	| convert gif:- ${.TARGET}

afnog-map.194x213.png: afnog-map.png
	convert -size 194x213 -resize 194x213 afnog-map.png gif:- \
	| convert gif:- ${.TARGET}
