Last active
April 24, 2020 13:24
-
-
Save Tonius/bc30fdd70626203bfaec1a3a8a4046fc to your computer and use it in GitHub Desktop.
GIMP plugin that adds new sprites to the Team CoFH website's recipe item sheet
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
#!/usr/bin/env python | |
from gimpfu import * | |
def recipe_sheet_add_sprites(img, layer, sprite_size, sheet_width, x, y): | |
gimp.progress_init('Adding layers to sheet...') | |
pdb.gimp_image_undo_group_start(img) | |
pdb.gimp_context_set_interpolation(INTERPOLATION_NONE) | |
try: | |
layers = img.layers[:-1] | |
for i, layer in enumerate(layers): | |
if layer.width != sprite_size or layer.height != sprite_size: | |
pdb.gimp_layer_scale(layer, sprite_size, sprite_size, FALSE) | |
pdb.gimp_layer_set_offsets(layer, x * sprite_size, y * sprite_size) | |
x += 1 | |
if x >= sheet_width: | |
x = 0 | |
y += 1 | |
gimp.progress_update(float(i + 1) / float(len(layers))) | |
except Exception as err: | |
gimp.message('Unexpected error: {}'.format(str(err))) | |
pdb.gimp_image_merge_visible_layers(img, EXPAND_AS_NECESSARY) | |
pdb.gimp_image_undo_group_end(img) | |
pdb.gimp_progress_end() | |
register( | |
'python_fu_recipe_sheet_add_sprites', | |
'Add sprites to recipe sheet', | |
'Adds sprites to the Team CoFH website\'s recipe item sheet', | |
'Ton Broekhuizen', | |
'', | |
'2017', | |
'<Image>/Filters/Minecraft/Add sprites to recipe sheet', | |
'RGB*', | |
[ | |
(PF_INT, 'sprite_size', 'Sprite size', 32), | |
(PF_INT, 'sheet_width', 'Sheet width', 16), | |
(PF_INT, 'start_x', 'Start X', 0), | |
(PF_INT, 'start_y', 'Start Y', 0), | |
], | |
[], | |
recipe_sheet_add_sprites | |
) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment