Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
poipoi300 committed Jan 10, 2024
1 parent 21573fa commit 8480c43
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontends/krita/krita_diff/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,22 @@ def cb(response):
)

def apply_prepare_inpaint(self):
# Add a new layer to use as the inpaint mask
mask_types = ["transparencymask", "filtermask", "colorizemask", "transfommask", "selectionmask"]
if str(self.doc.activeNode().type()) in mask_types:
# Adding layers won't work on mask_types, so we need to add the layer from the parent
self.doc.setActiveNode(self.doc.activeNode().parentNode())

layer = self.doc.createNode("Inpaint Mask", "paintLayer")
layer.setOpacity(204) # 80% opacity so the user can see the content behind the inpaint layer
parent = self.doc.activeNode().parentNode()
parent.addChildNode(layer, None) # We don't keep track of this layer because we're intending to use it for future generations

if parent is not None:
parent.addChildNode(layer, None)
else: # This would happen in case of a global selection, we add to the root to avoid adding to None
self.doc.rootNode().addChildNode(layer, None)

# Switch to the brush too in case another tool was selected, so the user can immediately draw their inpaint mask
# Switch to the brush in case another tool was selected, so the user can immediately draw their inpaint mask
self.app.action("KritaShape/KisToolBrush").trigger()

all_brushes = self.app.resources('preset')
Expand Down

0 comments on commit 8480c43

Please sign in to comment.