diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 14:39:16 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2025-01-08 14:39:16 +0100 |
commit | 18a8813645187102fc6261b8d5be1a41c8f0dae4 (patch) | |
tree | 655c5d22027fa23af3378df2d92d4051a71be2a6 /game/util/scrollgen | |
parent | 0729209117a4393e66d7f5b6d83083e2d7c0694c (diff) | |
parent | d9c67da9b8c2d8d25ef4dd2c700ddc78573d3a60 (diff) |
Merge remote-tracking branch 'origin/loek/game' into niels/game
Diffstat (limited to 'game/util/scrollgen')
-rwxr-xr-x | game/util/scrollgen | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/game/util/scrollgen b/game/util/scrollgen new file mode 100755 index 0000000..0389107 --- /dev/null +++ b/game/util/scrollgen @@ -0,0 +1,36 @@ +#!/bin/sh +INPUT="$1" +FRAMES="$2" + +die() { + echo "$@" + exit 1 +} +check_command() { + cmd="$1" + command -v "$cmd" > /dev/null || die "command '$cmd' not found" +} + +check_command magick +check_command identify +[ "$#" -eq 2 ] || die "usage: $0 <input image> <frame count>" +[ -e "$INPUT" ] || die "file not found: $INPUT" +[ "$FRAMES" -gt 0 ] || die "invalid frame count: $FRAMES" + +tile_width=$(identify -format "%w" "$INPUT") +tile_height=$(identify -format "%h" "$INPUT") + +OUTPUT="$INPUT.scroll.png" +magick -size "${tile_width}x$(( $tile_height * $FRAMES ))" 'xc:#ff00ff00' "$OUTPUT" + +for i in $(seq 0 $(( $FRAMES - 1 ))); do + offset_x=$(( $tile_width * $i / $FRAMES )) + offset_y=$(( i * $tile_height )) + + magick "$OUTPUT" "$INPUT" -geometry "+${offset_x}+${offset_y}" -composite "$OUTPUT" + magick "$OUTPUT" "$INPUT" -geometry "+$(( $offset_x - $tile_width ))+${offset_y}" -composite "$OUTPUT" + echo "+${offset_x}+${offset_y}" +done + +# magick -size ${total_width}x${sprite_height} xc:none canvas.png + |