Skip to content

Instantly share code, notes, and snippets.

@KPCCoiL
Created August 6, 2019 13:48
Show Gist options
  • Save KPCCoiL/e13b96c94419c595a79c662be95e9432 to your computer and use it in GitHub Desktop.
Save KPCCoiL/e13b96c94419c595a79c662be95e9432 to your computer and use it in GitHub Desktop.
generate moving gifs from any 64x64 pic
function dir-opt
set fmt
set sig
switch $argv[1]
case left
set fmt "+%d+0"
set sig '(-1)'
case right
set fmt "+%d+0"
set sig 1
case up
set fmt "+0+%d"
set sig '(-1)'
case down
set fmt '+0+%d'
set sig 1
end
set frame $argv[2]
set trans (echo "$sig * ($frame * 32 / 6)" | bc)
printf $fmt $trans
end
set dirs left right up down
if [ (count $argv) != 1 ]
echo "usage : this-script image-of-64x64"
exit 1
else
set image $argv
for from in $dirs
for to in $dirs
mkdir "$from-$to"
for i in (seq 0 11)
set j (echo "$i - 12" | bc)
convert -size 64x64 xc:white \
$image -geometry (dir-opt $to $i) -composite \
$image -geometry (dir-opt $from $j) -composite \
$from-$to/frame-$i.gif
end
convert -delay 6 -dispose background $from-$to/frame-*.gif -loop 0 $from-$to/$from-$to.gif
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment