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

Python: Selecting opaque/visible pixels.

Tags: None
(comma "," separated)
saedjubarin
Registered Member
Posts
58
Karma
0
Is there a libkis way to select opaque pixels with rectangle? Should I process pixelData with some other library? Maybe you have a suggestion how to do it? I can ofcourse go through the pixelData pixel by pixel and then (maybe) offset it by the layer position, but it seems cumbersome.

For those interested the intention is to crop the opaque part of the layer and use it as the brush tip with a keystroke.
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
Why not trigger the "deselect" and "selectopaque" actions and then use the resulting selection?
saedjubarin
Registered Member
Posts
58
Karma
0
TheraHedwig wrote:Why not trigger the "deselect" and "selectopaque" actions and then use the resulting selection?


Sounds fantastic! Where do I find these actions?
User avatar
rbreu
Registered Member
Posts
52
Karma
0
In Krita, in the Select menu. From Python, you can call actions like this:

Code: Select all
app = krita.Krita.instance()
app.action('selectopaque').trigger()


There's also selectopaque_add, selectopaque_subtract and selectopaque_intersect.
saedjubarin
Registered Member
Posts
58
Karma
0
Found the actions with this:
Code: Select all
app = Krita.instance()
#print("\nKrita.instance():\n",dir(app))
print("\nKrita.instance().actions()[0]:\n",dir(app.actions()[0]))
print("\n[action.objectName() for action in Krita.instance().actions()]:\n", [action.objectName() for action in app.actions()] )
saedjubarin
Registered Member
Posts
58
Karma
0
rbreu wrote:In Krita, in the Select menu. From Python, you can call actions like this:

Code: Select all
app = krita.Krita.instance()
app.action('selectopaque').trigger()


There's also selectopaque_add, selectopaque_subtract and selectopaque_intersect.


Thank you!


Bookmarks



Who is online

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