Restrict Wrap Around Mode to Selection

It would be nice if you could restrict wrap around mode to only work within a selection. This would make the workflow of creating a tilemap (for games) considerably better.

Usually my workflow looks like this:

I draw complete shapes like this to create a tilemap base, with a grid as a guide for each tile:

Then I have to select one tile (or group of tiles if they belong together) and put them in a seperate file which has the canvas set up so I can use Wrap Around Mode.
After that I have to copy them from that file back into my original.

Feature Request:
It would be nice If I could make a selection (shown in red):

and apply wraparound temporarily only to the selection, paint a bit to make looping tiles, to then go out of wrap around and continue painting as normal.

Going in and out of different files is not only a little bit finicky as you have to make sure the images are positioned correctly, but it also makes you very tunnel visioned on the specific tile you’re working on. If you could switch to view the whole tileset every now and then it could help to see the bigger picture of what you’re working on.

Im sure this could be usefull for other cases aswell such as, when you want to add a looping texture to a painting without losing the feel of your original painting.

Let me know if anyone has a better workflow for this out there!

1 Like

Have you tried to replace the step of copying with File Layer?

You can use another krita file as an input.

One way to teeak your workflow is to have multiple file layers, responsible for each section.

Then you can make a directory for your particular tilemap and like all the files together.

The neat thing is with file layer you will get updates in the combined files right after the source is saved. Meaning you can have multiple parts edited at the same time.

2 Likes

Thanks for the suggestion! I will try this

I agree that using file layers would make it easier. But I still think this idea is interesting. It might be a lot of work to implement properly in Krita itself, but I thought of a way to do something similar with a script instead.

I made a quickly-written script that toggles between resizing the image to the selection (keeping the content offcanvas) and resizing the image to the contents, while also toggling wraparound mode.

# A script to toggle the image size between the selection and the content,
# and toggle wraparound mode
from krita import *

def accumulateBounds(parentNode, sum):
    sum |= parentNode.bounds()
    for child in parentNode.children():
        accumulateBounds(child, sum)

doc = Krita.instance().activeDocument()
selection = doc.selection()
if selection:
    if selection.width() == doc.width() and selection.height() == doc.height():
        # same as selection: expand image to content
        sum = QRect(doc.xOffset(),doc.yOffset(),doc.width(),doc.height())
        for topLevelNode in doc.topLevelNodes():
            accumulateBounds(topLevelNode, sum)
        doc.resizeImage(sum.x(), sum.y(), sum.width(), sum.height())
        
    else:
        # resize image to selection (without removing content)
        doc.resizeImage(selection.x(), selection.y(), selection.width(), selection.height())

Krita.instance().action("wrap_around_mode").trigger()

It could be bound to a Ten Scripts shortcut.

6 Likes

Pretty interesting workaround!