Created
May 15, 2014 01:52
-
-
Save jonongjs/3a74c8c79be0722f3171 to your computer and use it in GitHub Desktop.
Quick and dirty script to generate a checkerboard transition spritesheet with ImageMagick.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Quick script to generate a checkerboard transition spritesheet with ImageMagick. | |
# This script makes PNGs with the names 'tile*.png', 'tmp.png', 'phase1_*.png', | |
# 'phase2_*.png' and 'checkerboard.png' in the current directory. | |
SIDE=20 # Width in pixels for each square | |
MAXN=5 # Number of steps - 1 to fill a square | |
TILES_ACROSS=16 # Number of squares across the checkerboard | |
TILES_DOWN=9 # Number of squares down the checkerboard | |
convert -size "$SIDE"x"$SIDE" xc:none tile0.png | |
for i in `seq 1 $MAXN` | |
do | |
WIDTH=$(($i*$SIDE/$MAXN)) | |
convert -size "$SIDE"x"$SIDE" xc:none -fill black -draw "rectangle 0,0 $WIDTH,$SIDE" tile$i.png | |
done | |
IMG_W=$(($TILES_ACROSS*$SIDE)) | |
IMG_H=$(($TILES_DOWN*$SIDE)) | |
for i in `seq 0 $MAXN` | |
do | |
montage tile0.png tile$i.png tile$i.png tile0.png -background none -tile 2x2 -geometry +0+0 tmp.png | |
convert -size "$IMG_W"x"$IMG_H" -background transparent tile:tmp.png phase1_$i.png | |
montage tile$i.png tile$MAXN.png tile$MAXN.png tile$i.png -background none -tile 2x2 -geometry +0+0 tmp.png | |
convert -size "$IMG_W"x"$IMG_H" -background transparent tile:tmp.png phase2_$i.png | |
done | |
montage phase1_*.png phase2_*.png -background none -geometry +0+0 checkerboard.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment