diff --git a/demo/addons/godot-krita-importer/krita_import_plugin.gd b/demo/addons/godot-krita-importer/krita_import_plugin.gd index c4b9866..ed78b34 100644 --- a/demo/addons/godot-krita-importer/krita_import_plugin.gd +++ b/demo/addons/godot-krita-importer/krita_import_plugin.gd @@ -16,6 +16,9 @@ var presets : Array[Dictionary] = [ "default_value": CanvasItem.TEXTURE_FILTER_PARENT_NODE, "property_hint": PROPERTY_HINT_ENUM, "hint_string": ",".join(range(0, CanvasItem.TEXTURE_FILTER_MAX)) + },{ + "name": "crop_to_visible", + "default_value": true }, ] @@ -126,6 +129,12 @@ static func import_paint_layer(layer_data : Dictionary, options: Dictionary) -> #create_from_data(width: int, height: int, use_mipmaps: bool, format: Format, data: PoolByteArray) var image = Image.create_from_data(layer_data.width, layer_data.height, false, layer_data.format, layer_data.data) + + if options.get("crop_to_visible", true): + var visible_region = image.get_used_rect() + image = image.get_region(visible_region) + sprite.position += Vector2(visible_region.position) + var texture = ImageTexture.create_from_image(image) sprite.texture_filter = options.get("texture_filter", CanvasItem.TEXTURE_FILTER_PARENT_NODE)