ShapesAndLayers Plugin [8 tools](Krita 5+)

I was gonna wait for the beta but had some time so figure I’ll just release it now.

It is effectively a collection of scripts that I polished up and made into a plugin. Make sure that you are on the LATEST Krita 5 build.

Shapes and Layers Krita Plugin

This plugin includes a collection of tools to manipulate layers, shapes and other convenience tools. (Requires Krita 5.0+)

Features

Split Shapes Into Layers

Usage: Layer->Split->Split Vector Shapes Into Layers...

Finds all shapes inside a vector layer and splits each shape into its own layer. Group shapes will be made into group layers, and shapes will be made into either their own vector layer or their own paint/raster layer depending on the option chosen.
You can also choose the depth you wish it to traverse by changing the top-level group depth option. By default, the top-level group setting is set to be equal to the top most non-group shape it finds.

Adjust Font Sizes

Usage: Tools->Shapes And Layers->Adjust Font Sizes...

Finds all text shapes within a document and adjusts them according to the operation chosen. This will also adjust text within the group shapes
The default 0.75 division is for restoring the font sizes to the Krita 4 sizes

~~ v.0.03 update ~~

Visibility Helper

Usage: Tools->Shapes And Layers->Layer Visibility Helper...

Provides convenience features for handling invisible layers.

Auto-select layer on making layer visible: When layer is made visible, select that layer

Block invisible layers: Make invisible layers more noticable for those who get tunnel visioned

Toggle visibility drag: Drag down or up to make multiple layers visible or invisible

Layer Styles Clipboard

Usage: Layer->Layer Styles Clipboard

Provides ability to copy, cut, paste and clear layer styles.
Shortcuts Available for configuration in Krita’s shortcut manager

~~ v.0.04 update ~~

A few fixes to the layer styles clipboard (such as usable on vector layers and group layers) and yet another new tool. Well, this one isn’t really related to shapes and layers but I kind of had it lying around so figured I’d just include it for those who want to save a bit of space in their UI.

Hide Dock Window Titlebars

Usage: Tools->Scripts->Shapes And Layers->Hide Dock Window Titlebars

Provides the ability to toggle the titlebars of Dock Windows on and off.
Holding Ctrl + Right mouse click will toggle individual dock windows. (If you click on child object of the window like a listbox, you may have to doubleclick)

~~ v.0.07 update ~~

Quite a lot of fixes in between, and 2 new features! Show Eraser and Font Manager Helper. For the Font Manager Helper, I was originally gonna add it to LazyTextTool but figured some people may wish to stay on the original text tool but want to take advantage of being able to play around with fonts without needing to install them or have Krita only fonts. So try a bunch of fonts you like without restarting Krita, then install them if you like them for next reset.

With this, Shapes And Layers now has 7 tools to play with. Once it reaches 10, I’ll probably change its name and let people install only the tools they wish to use as I don’t want to over bloat things.

Font Manager Helper

Usage: Tools->Scripts->Shapes And Layers->Font Manager Helper...

Provides the ability to add and remove temporary fonts without restarting Krita.

Manual: You can add 1 or more fonts that will be added temporarily. Fonts are automatically removed when Krita is restarted.

Auto: Monitor a temporary directory for new fonts and add/remove the fonts in realtime. If left running, it will resume next time Krita is opened and add all the fonts in the directory. Subdirectories are not supported. This is not intended for monitoring system font folders.

Old v0.07 Show Eraser

Show Eraser

Usage: Tools->Scripts->Shapes And Layers->Show Eraser Cursor

Changes the cursor into a visible eraser when the eraser is selected.

~~ v.0.08 update ~~

From now on, I’ll only do releases when most bugs of the new features have been tested (cause so far, the releases end up the most buggiest and all the fixes come later once people test them). So download via clicking Code->Download Zip. While working on the Show Eraser feature, I got a bit annoyed with managing of shapes when they are close to each other. So to help make the experience more user friendly, Shapes As Layers feature has been added!

Show Eraser

Usage: Tools->Scripts->Shapes And Layers->Show Eraser Cursor->Enable

Changes the cursor into a visible eraser when the eraser is selected.

You can configure custom cursor SVG/PNG and set size with 4 different modes accross 3 different zoom levels.

Default Size: Use default cursor.

Static: Size of cursor will be exactly the number set.

Adjust: Cursor will adjust based on zoom level.

Hide: Cursor will be hidden.

Shapes As Layers

Usage: Settings->Dockers->Shapes As Layers

A docker that allows you to see and select shapes on a vector layer as though each shape is its own layer. You can also view the SVG of said shape by pressing the Edit button.

Note: Shapes will only show when the Shape Select Tool is used.

https://github.com/KnowZero/Krita-ShapesAndLayers-Plugin

14 Likes

Wow, I have seen someone request this function of csp in the forum before.In my actual experience, I always drag the layer to other positions easily.And every time it goes to the copied layer, it will go wrong(The vector layer split using the plug-in will also be wrong)

NameError
Python 3.8.1: C:\GAMES\STEAM\steamapps\common\Krita\krita\bin\krita.exe
Fri Aug 20 19:20:17 2021

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayersVisibilityHelper.py in layerHover(self=<ShapesAndLayers.ShapesAndLayersVisibilityHelper.ShapesAndLayersVisibilityHelper object>, idx=<PyQt5.QtCore.QModelIndex object>)
160 doc = Krita.instance().activeDocument()
161
162 node = self.validateNode(doc, doc.nodeByName(layerName),idx)
163
164 node.setVisible(self.hoverToggleMode[1])
node undefined
self = <ShapesAndLayers.ShapesAndLayersVisibilityHelper.ShapesAndLayersVisibilityHelper object>
self.validateNode = >
doc = <PyKrita.krita.Document object>
doc.nodeByName =
layerName = ‘副本自 颜料图层 6’
idx = <PyQt5.QtCore.QModelIndex object>

C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayersVisibilityHelper.py in validateNode(self=<ShapesAndLayers.ShapesAndLayersVisibilityHelper.ShapesAndLayersVisibilityHelper object>, doc=<PyKrita.krita.Document object>, node=<PyKrita.krita.Node object>, idx=<PyQt5.QtCore.QModelIndex object>)
149 for i in reversed(idxMap):
150 onNode = onNode.childNodes()[i]
151 if onNode.name() == layerName: node = onNode
152
153 return node
onNode = <PyKrita.krita.Node object>
onNode.name =
layerName undefined
node = <PyKrita.krita.Node object>
NameError: name ‘layerName’ is not defined
cause = None
class = <class ‘NameError’>
context = None
delattr = <method-wrapper ‘delattr’ of NameError object>
dict = {}
dir =
doc = ‘Name not found globally.’
eq = <method-wrapper ‘eq’ of NameError object>
format =
ge = <method-wrapper ‘ge’ of NameError object>
getattribute = <method-wrapper ‘getattribute’ of NameError object>
gt = <method-wrapper ‘gt’ of NameError object>
hash = <method-wrapper ‘hash’ of NameError object>
init = <method-wrapper ‘init’ of NameError object>
init_subclass =
le = <method-wrapper ‘le’ of NameError object>
lt = <method-wrapper ‘lt’ of NameError object>
ne = <method-wrapper ‘ne’ of NameError object>
new =
reduce =
reduce_ex =
repr = <method-wrapper ‘repr’ of NameError object>
setattr = <method-wrapper ‘setattr’ of NameError object>
setstate =
sizeof =
str = <method-wrapper ‘str’ of NameError object>
subclasshook =
suppress_context = False
traceback =
args = (“name ‘layerName’ is not defined”,)
with_traceback =

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
File “C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayersVisibilityHelper.py”, line 162, in layerHover
node = self.validateNode(doc, doc.nodeByName(layerName),idx)
File “C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayersVisibilityHelper.py”, line 151, in validateNode
if onNode.name() == layerName: node = onNode
NameError: name ‘layerName’ is not defined

This is the error I encountered when splitting the vector layer

AttributeError
Python 3.8.1: C:\GAMES\STEAM\steamapps\common\Krita\krita\bin\krita.exe
Fri Aug 20 19:37:40 2021

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayers.py in slotSplitLayer(self=<ShapesAndLayers.ShapesAndLayers.ShapesAndLayers object>)
45
46 result = sl.openDialog()
47 self.errMsg(result)
48
49 def slotFontAdjust(self):
self = <ShapesAndLayers.ShapesAndLayers.ShapesAndLayers object>
self.errMsg undefined
result = {‘status’: 1}
AttributeError: ‘ShapesAndLayers’ object has no attribute ‘errMsg’
cause = None
class = <class ‘AttributeError’>
context = None
delattr = <method-wrapper ‘delattr’ of AttributeError object>
dict = {}
dir =
doc = ‘Attribute not found.’
eq = <method-wrapper ‘eq’ of AttributeError object>
format =
ge = <method-wrapper ‘ge’ of AttributeError object>
getattribute = <method-wrapper ‘getattribute’ of AttributeError object>
gt = <method-wrapper ‘gt’ of AttributeError object>
hash = <method-wrapper ‘hash’ of AttributeError object>
init = <method-wrapper ‘init’ of AttributeError object>
init_subclass =
le = <method-wrapper ‘le’ of AttributeError object>
lt = <method-wrapper ‘lt’ of AttributeError object>
ne = <method-wrapper ‘ne’ of AttributeError object>
new =
reduce =
reduce_ex =
repr = <method-wrapper ‘repr’ of AttributeError object>
setattr = <method-wrapper ‘setattr’ of AttributeError object>
setstate =
sizeof =
str = <method-wrapper ‘str’ of AttributeError object>
subclasshook =
suppress_context = False
traceback =
args = ("‘ShapesAndLayers’ object has no attribute ‘errMsg’",)
with_traceback =

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
File “C:\Users\123\AppData\Roaming\krita\pykrita\ShapesAndLayers\ShapesAndLayers.py”, line 47, in slotSplitLayer
self.errMsg(result)
AttributeError: ‘ShapesAndLayers’ object has no attribute ‘errMsg’

Thanks, both have been fixed.

1 Like

Now this plugin is working very well.
In addition, I have some suggestions for a new feature. This feature is used to create a “clip group” for interacting with other software.

Duplicate the layer and hide the original layer
Convert to paintlayer (grouplayer, vector layer)/flatten layer (paintlayer)
create_quick_group
split_alpha_into_mask
move_layer_up
add_new_paint_layer

If it selects multiple layers, first copy, group, and then merge…
Then we can set shortcut keys for it
This should not be difficult to achieve. I simply completed a prototype with basic actions in the 4.0 era. But it seems that 5.0’s decision on active nodes has changed. At my level, it may take a lot of time to perfect it. But it is very suitable to be included in this plugin about layers

If you want to add a pull request for an additional feature, sure, all of them are welcome. If you want me to add it myself, I don’t mind but it would have to go into the queue which is:

stop being sick :frowning_face: > LazyTextTool for krita 5.0 fixups > Vertical text

After that is done, I don’t mind.

There really hasn’t been much changes on active nodes as far as the api goes… only more things that can be done with nodes.

1 Like

Being able to adjust multiple texts is super cool! Thanks for the plugin! (I want it as an official feature someday)

Could you make it possible to align or fix font sizes at a certain number(size) aside from being able to add, multiply, divide numbers etc?

that shouldn’t be too hard.

Edit: The fixed font size has been added since it is pretty straight forward. The other will have to wait till I get better.

1 Like

I’ve been wishing for something like this for ages because I like to use Krita to add texture and lighting to vectors done in Inkscape. Previously I was splitting the shapes onto layers manually so this will be a god send.

Thank you!

1 Like

[Testing including 0.05]
Much thanks for adding fixed sized option. :smiling_face_with_three_hearts:

One thing I noticed :
When undoing the operation Krita undo every texts individually, and temporarily erase the target text before undoing its change. I’m not sure if it’s a bug or intended tho.

There isn’t much I can do there, the problem is the current API has no transaction support. So everything is an individual action.

Once transaction support is added (which won’t be in 5.0 as it is too late), then I will update it to undo all at once.

~~ v.0.07 update ~~

Quite a lot of fixes in between, and 2 new features! Show Eraser and Font Manager Helper. For the Font Manager Helper, I was originally gonna add it to LazyTextTool but figured some people may wish to stay on the original text tool but want to take advantage of being able to play around with fonts without needing to install them or have Krita only fonts. So try a bunch of fonts you like without restarting Krita, then install them if you like them for next reset.

With this, Shapes And Layers now has 7 tools to play with. Once it reaches 10, I’ll probably change its name and let people install only the tools they wish to use as I don’t want to over bloat things.

Font Manager Helper

Usage: Tools->Scripts->Shapes And Layers->Font Manager Helper...

Provides the ability to add and remove temporary fonts without restarting Krita.

Manual: You can add 1 or more fonts that will be added temporarily. Fonts are automatically removed when Krita is restarted.

Auto: Monitor a temporary directory for new fonts and add/remove the fonts in realtime. If left running, it will resume next time Krita is opened and add all the fonts in the directory. Subdirectories are not supported. This is not intended for monitoring system font folders.

Show Eraser

Usage: Tools->Scripts->Shapes And Layers->Show Eraser Cursor

Changes the cursor into a visible eraser when the eraser is selected.

1 Like

I use the ThreeSlots plugin, and it doesn’t seem to recognize the eraser mode.
When I close “show easter cursor”, the icon also appears. When I switch the normal brush, it always exists
Another time, when the mouse moved outside the canvas, there was only the icon of the eraser, but no cursor…

What about when you use it without the plugin? (want to be sure it is working properly before extra variables)

The cursor turns into the eraser, I’m not doing an overlay here to simplify it.
It should generally turn back when you leave the canvas. Also, to confirm, you are on Windows or a different OS? and using tab or subwindow mode?

Edit: I fixed the toggling off thing.

Edit2: Okay, I think I fixed the other issues. It will probably fix the problem with the other plugin too.

It’s close to normal, but the eraser mode seems to be disabled?

There are some other minor issues:
Can the icon of the eraser be scaled? Sometimes it’s obvious, sometimes it’s small
On dark colors, the icon of the eraser is not obvious, and you can’t see it at all on black. I think a more saturated color is needed.

This is for normal operation or for the plugin? Can you clarify a bit?

What resolution are you on? Currently I have it set to 32x32 and if your screen with is above 3000 it scales to 64x64

I added a white outline that should make it a bit more clearer on dark colors

Normal operation.I just clicked the icon in the toolbar, but it didn’t work
EDIT: This is the fault of the threeslots plugin…

I mean it will change with the zoom of the canvas
image
Sometimes it’s only so small

I can see it now, but the overall zoom is still not obvious

It might be due to the event order, while I can’t guarantee full compatibility with other plugins, I’ll take a quick look after work.

Uhm, the size should be static regardless the size of the brush or canvas, are you saying it ends up scaling with zoom on your pc? Again to confirm what OS are you using and what resolution?

This is not a compatibility issue. This seems to be its setting…
Pressing the shortcut key set by threeslots will cause this result. But I just used the mouse to test before, so I was confused

windows 2560x1080

I want it to zoom like krita’s brush cursor
4

ah, okay so there is no issue then?

Hmm, can I ask what the intention is? I mean wouldn’t zooming out mean you wouldn’t be able to see that it is in eraser mode? Or is it because it is blocking your screen?

Overall, this seems more like a preference. But it shouldn’t be a problem to add in the next revision when I figure out what other preferences people want and bundle them up. Maybe things like letting people choose their own custom cursor instead of the default one and etc.

yes


When I shrink the canvas, it's too big; when I enlarge it, it's too small to see

I wish there was a thicker solid red icon. The current cursor is still not very visible to me