This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Onion Skin -like feature for layers

Tags: None
(comma "," separated)
saedjubarin
Registered Member
Posts
58
Karma
0

Onion Skin -like feature for layers

Wed Mar 13, 2019 7:43 pm
I'm creating a bunch of animated brushes for each painting I do, because they're just that great.

Sometimes I make simple forms with loads of variation, loads of layers. To cut from the brush creation time, an automatic opacity reduction of some sort would be fantastic.
ahabgreybeard
Registered Member
Posts
1269
Karma
11
OS
If you create your brush images as frames in an animated layer, using grey colours in an RGB/A colour space, you can use the onion skins. Then you Render the animation out as a set of images (.png files). Then Layer -> Import the .png files all at the same time into a new image (where they will go into separate layers) then convert to greyscale colourspace so you can Export them as a .gih file.
saedjubarin
Registered Member
Posts
58
Karma
0
ahabgreybeard wrote:If you create your brush images as frames in an animated layer, using grey colours in an RGB/A colour space, you can use the onion skins. Then you Render the animation out as a set of images (.png files). Then Layer -> Import the .png files all at the same time into a new image (where they will go into separate layers) then convert to greyscale colourspace so you can Export them as a .gih file.


Thanks! I thought I'd solve this whole ordeal by making a python plugin, but your approach is nice too! Still making the python plugin though.
saedjubarin
Registered Member
Posts
58
Karma
0
I made a crude python script to handle "Onion Skinning" while adding new layers. It only adjusts the opacities of the layers. Use a script to show the layers when finished or something.

The relevant part is BrushAnimator.new() in this piece of plugin:

Code: Select all
from krita import Extension,  Krita

class BrushAnimator(Extension):

    def __init__(self, parent):
        #Always initialise the superclass.
        #This is necessary to create the underlying C++ object
        super().__init__(parent)
        self.current = "init"
        self.doc = app.activeDocument()

    def setup(self):
        pass

    def createActions(self, window):
        action_next = window.createAction("ba_next", "Brush Animator: Next","tools/scripts")
        # parameter 1 =  the name that Krita uses to identify the action
        # parameter 2 = the text to be added to the menu entry for this script
        # parameter 3 = location in Krita menu to put this script entry
        action_next.triggered.connect(self._next)
        action_start = window.createAction("ba_start", "Brush Animator: Start","tools/scripts")
        action_start.triggered.connect(self.start)
        action_start = window.createAction("ba_new", "Brush Animator: New Layer","tools/scripts")
        action_start.triggered.connect(self.new)
       
    def _next(self):
        print("Brush Animator: Next")
        self.toplevel = self.doc.topLevelNodes()
        if self.current == "init":
            self.start()
        else:
            n_nodes = len(self.toplevel)
            self.toplevel[self.current%n_nodes].setVisible(False)
            self.current = (self.current + 1) %n_nodes
            self.toplevel[self.current].setVisible(True)
            self.doc.setActiveNode(self.toplevel[self.current])
            self.doc.refreshProjection()
            app.activeWindow().activeView().setVisible()

    def start(self):
        print("Brush Animator: Start")
        self.doc = app.activeDocument()
        self.toplevel = self.doc.topLevelNodes()
        self.current = 0
        for node in self.toplevel:
            node.setVisible(False)
        self.toplevel[self.current].setVisible(True)
        self.doc.setActiveNode(self.toplevel[self.current])
        self.doc.refreshProjection()
        app.activeWindow().activeView().setVisible()

    def new(self):
        print("Brush Animator: New")
        self.doc = app.activeDocument()
        nodes = self.doc.topLevelNodes()
        new_node = self.doc.createNode("PyLayer %s"%len(nodes), "paintLayer")
        root = self.doc.rootNode()
        root.addChildNode(new_node, None)
        self.doc.waitForDone()
        nodes = self.doc.topLevelNodes()
        idx = 0
        for node in nodes[::-1]:
            node.setOpacity(max(0,255-(255//5)*idx))
            idx += 1
        self.doc.refreshProjection()
       
# And add the extension to Krita's list of extensions:
app=Krita.instance()
extension=BrushAnimator(parent=app) #instantiate your class
app.addExtension(extension)


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Evergrowing, Google [Bot], rblackwell