Skip to content

Commit

Permalink
unslice multitile script, tall multitile template (I-am-Erk#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
int-ua authored Dec 21, 2020
1 parent eac89ae commit 697babd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
__pycache__
# generated on build
gfx/*/tile_config.json

Expand Down
Binary file added templates/multitile_grid_4x4.xcf
Binary file not shown.
Binary file added templates/multitile_grid_4x4_tall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/multitile_grid_4x4_tall.xcf
Binary file not shown.
20 changes: 9 additions & 11 deletions tools/slice_autotiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
import pathlib
import pyvips

parser = argparse.ArgumentParser(description="Slice an autotile image")
parser.add_argument("tile", help="base name of the tile")
parser.add_argument("size", type=int, help="tile size in pixels")
parser.add_argument("image", help="path to autotile image")
parser.add_argument("out", help="output path")
parser.add_argument("--no-json", action='store_true',
help="disable json file generation")


MAPS = {
48: {
Expand Down Expand Up @@ -60,8 +52,7 @@
}


def main():
args = parser.parse_args()
def main(args):
img = pyvips.Image.new_from_file(args.image)

pathlib.Path(args.out).mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -136,4 +127,11 @@ def main():


if __name__ == "__main__":
main()
parser = argparse.ArgumentParser(description="Slice an autotile image")
parser.add_argument("tile", help="base name of the tile")
parser.add_argument("size", type=int, help="tile size in pixels")
parser.add_argument("image", help="path to autotile image")
parser.add_argument("out", help="output path")
parser.add_argument("--no-json", action='store_true',
help="disable json file generation")
main(parser.parse_args())
28 changes: 28 additions & 0 deletions tools/unslice_multitile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
'''
Combine a set of multitile sprites into 4x4 grid
'''

import argparse
import pyvips

from slice_autotiles import MAPS


def main(args):
multitile_dict = {}

for suffix, position in MAPS[16].items():
sprite = pyvips.Image.new_from_file(f'{args.tile}_{suffix}.png')
multitile_dict[position] = sprite

output_img = pyvips.Image.arrayjoin(
[multitile_dict[i] for i in range(16)], across=4)
output_img.pngsave(f'{args.tile}_multitile.png')


if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Combine a set of multitile sprites')
parser.add_argument('tile', help='base name of the tile')
main(parser.parse_args())

0 comments on commit 697babd

Please sign in to comment.