[Proof of Concept] Plugin as Eraser Tool (PET)

Hello,

I bring news. My first krita plugin

I just hope this don’t just crash and burn :rofl:

DISCLAIMER!

This is a prototype and highly likely to break or not work as intended, without any way to fix it!

This plugin was made as a proof of concept, using the Python API in an unintended way (probably), a bunch of hard-coded mess and …

a secret ingredient


Or what it feels like it when you dig into the code.

Notes

The following plugin is what I would call a ‘pre-alpha’ version (version 0.1)
Any feedback or bug report is welcome, but keep in mind that any bug might be ‘un-fixable’ due the current implementation.

Requirements

Krita version 5.2.0 or higher.
This plugin utilize a newer version of the Python API, thus the strict version requirement

Testing

Only tested using the krita-5.2.0-prealpha Linux appimage


[22/09/2022] PET v0.1 (Prototype)

What is PET?

PET is a Python Plugin. It serves as prototype for an ‘Eraser Tool’ into Krita.

This plugin intents to add a shortcut for Non-Eraser brushes, and another for Eraser brushes. Thus mimicking the behavior of an dedicated Eraser Tool.

Functionality

Krita start-up time will increase drastically the First Time the plugin run. That is due the process which the plugin access, analyses and categorize the brushes. Following sessions should have a normal start-up time, as long your brushes remains the same.

This plugin scan all available brushes in Krita, and creates two list out of them. The first list of all Non-Erasers brushes (list 1) and the other of all the Erasers brushes (list 2).

By default this plugin has two shortcuts, both activate the Free Hand Brush Tool. The first one ‘remember’ the last selected Non-Eraser brush. The second one ‘remember’ the last selected Eraser brush.

How to

The default shortcuts are defined as:

  • Brush slot → Ctrl+Alt+Shift+P
  • Eraser slot → Ctrl+Alt+Shift+O
  • Update Brush List → Ctrl+Alt+Shift+A

The plugin should capture the current brush selected and assign it to the proper slot. This behavior was tested using the Brush Preset Docker, the Brush Preset in the Tool Bar, the Popup Palette and the shortcuts Previous Favorite Preset / Next Favorite Preset.

Using others plugins (Ten Brushes, BuliBrushSwitch) for changing presets weren’t test.

Updating the Brush List

Under specific circumstances, the plugin can update the list of brushes either automatically or manually, these being:

-Automatically:

  • The plugin is being ran for the first time
  • The name or number of brushes have changed
  • After installing or deactivating bundles
  • Something is wrong with the Brush List save file

-Manually:

  • Via the shortcut Update Brush List. Default key combination (Ctrl+Shift+Alt+A)

ATTENTION!
The save file only has a reference to the preset names. So changing a brush to an eraser (or vice-versa), and saving it with the same name will not update the brush list when Krita starts. In this case update the brush list manually.

6 Likes

Awesome plugin. I will test it in free time.

One thing to note is that people who want dedicated eraser tool from photoshop need a different behaviour. In photoshop once you are in eraser tool, you can select any brush and use it as an eraser, not just the brush which are erasers. So for photoshop users there is no concept of non brush erasers, because once they activate eraser tool every brush is eraser for them. It is like a globally locked erase mode which applies to all brushes.

3 Likes

Thank you for this. I’ll be sure to test it out.

You say this is a prototype/proof of concept, do you mean this as to gather thoughts for a native (non-plugin) eraser tool?

2 Likes

Sorry, but can’t I alreay just hit “E” in Krita and turn any brush into an eraser?

You can, but many times people have requested for another dedicated tool which can be activated both via toolbar icon or shortcut to access all the brushes which will work as erasers when this tool is active. This tool will have its own history too so that people can switch between past used brushes as erasers and this will help them use a different type of brush as eraser like hard round basic brush, in addition to using existing brush as eraser which sometimes can have low opacity etc.

I agree,
I got used to just switching to the previous brush and then just hit “E”->where my previous brush is the eraser brush I want to use. But when I came from photoshop I did miss the explicit binding between the eraser tool and the shortcut “E”. Maybe this Prof of Concept will open up more possibilities for a better UX design.

2 Likes

I think it’s great that we’re having this discussion btw.
I think that generally Krita’s way of handling brushes and erasers is much better than Photoshop. I remember when Photoshop introduced their way of hard-binding a brush to a certain tool it annoyed the hell out of me and I had to re-save all the brushes to be tool-agnositic.
But generally having brushes and erases having their own presets is great, and being able to quickly change a brush to an erases hitting “E” is even better.
I guess what I personally would love is a working way to assign brushes in the pop-up palette to keystrokes. Something that should theoretically work with the “ten brushes” script, but which I wasn’t able to make work.
Having that built into the pop-up palette would be even better maybe.

So my 2c would be: we don’t need Krita to mimick PS, but there is room for improvement with how it currently works.

1 Like

No to go too offtopic in this thread, I think we should limit the discussion to the plugins behaviour.
for further discussion you can see this topic -

1 Like

Hey.

I think you are wrong here, but maybe I’m not understanding it correctly. In Photoshop a “brush preset” is either an eraser or brush. If I’m in eraser mode and select a brush from the presets, Photoshop automatically switches to the brush tool.

When has that changed? I recall having seen both behaviours in Photoshop at some point in time tbh. So what @raghukamath mentioned also used to be a Photoshop behaviour, because I know I have used the grass brushes as erasers too.

There’s the tilde key that you can temporarily press to turn the brush into an eraser, but as far as tools and presets are concerned there’s either brush or eraser. At least as far as I know.^

[EDIT] I just learned that you can set the blending mode of a brush to “Clear” as well to turn the brush into an eraser. So it’s possible to create a brush preset with that mode enabled and the brush would function as an eraser. But that’s not how it’s usually done. The standard procedure is to save brush and eraser presets as the actual tool.

Thanks, hope you like the idea.

This behaviour you described is what the plugin Three Slots do. When you activate the Eraser Slot every brush selected becomes an eraser. For painting you have to activate the Brush Slot before selecting a new ‘paint brush’.

The downside of the plugin mentioned above is ‘readability’. More often then not while testing I would forget the Eraser Mode was On and would mess up the whole thing. A tool like this has to have a GUI, a docker or toolbar insert of the brush and eraser slot. So the user can see which tool is active and what brush is assign to it.
Relaying only in keyboard shortcuts for changing, and the user memory of which tool is active is too cumbersome.

2 Likes

Thanks for testing it.

It’s a prototype aiming to refining and expanding the Python API, so it can have proper support for plugins that want to interact with Krita in a similar manner of this plugin. (or at least propose a direction for its development)
Under the hood my plugin is accessing the resources (Brush Presets) using a portion of the Python API, that I’m pretty sure it shouldn’t be (fully) used at runtime. That’s why the start up is massively delayed at first, and why the plugin relies on a list of brush names afterwords.
The ‘worst’ thing is how the plugin knows when a brush is changed. It relies onto Krita’s UI and signals that a plugin shouldn’t be using (Le crime), and not on some proper system dedicated to it.


Not from my part. Actually I believe there a 99% chance of not happening.
I can’t confirm as I never talked to the Devs, or read explicitly anywhere but the following is my own understanding of the matter.

Krita philosophy is that when an user wants to freely paint they should use the Free Hand Tool, and everything related to free painting should be under it. When you think about it, it is a cool idea there is no separation of ‘Pencil Tool’, ‘Smudge Tool’, ‘Brush Tool’ or ‘Eraser Tool’.
So implementing a dedicated Eraser Tool could probably be rejected to be merged into Krita’s code, as it could change its identity.
However this is something @halla or @tiar would have authority to confirm or not. :smile:

I just checked PS. Apparently you can attach tool settings when creating a brush. If you do then the brush preset image has a small icon which represents that tool (brush, eraser, finger, etc.), and if you select that preset then the tool also switches. If the preset does not have the tool options attached, then when selecting it the tool does not change unless you have a non-painting tool selected. In that case selecting the brush preset also selects the brush tool.

1 Like

Yeah. You’re right. But I’ve actually never used it that way and when I look at the brush collections that I gathered over time, usually there’s a tool associated with a preset. This makes sense. Cause when you pick a preset from the list, you want to be ready to go, no matter if you are in the brush or eraser tool. Otherwise you would have to occasionally also switch the tool as well, which can become tedious and confusing. That’s why I never unchecked that option myself.

1 Like

I have cross-posted this to the feature request topic for a dedicated eraser as well: being able to have smoothing and/ or snapping enabled for the freehand brush and disabled for an eraser tool would save a lot of toggling back and forth for these settings.

1 Like

As of 5.1.0, eraser snapping is always disabled by default. There have been at least a couple merge requests for separate smoothing but they were rejected/closed due to buggy implementations.

The value here is being able to switch between a preferred brush and a preferred eraser as seamlessly as possible, as many brushes don’t have ideal behavior when switching to eraser mode, regardless of the fact that you can specify separate sizes/opacities, which I don’t think are even saved to the brush in the first place.

Some thoughts:

  • I prefer it over ThreeSlots. Not only did ThreeSlots have some functional problems (like an annoying timer function after switching slots) that I had to locally patch myself, but the general UX here is less confusing, especially since in the case of changing the brush of a particular slot/tool, you don’t have to select the slot first before selecting the corresponding brush.
  • There has been at least one case where the plugin didn’t recognize a tool changing its corresponding brush (specifically, the saved brush config didn’t seem to update properly when changing brushes, so the shortcuts would select one particular brush they’re stuck on until restarting Krita, regardless of selecting new brushes.). But I haven’t figured out the reason why, and it seems like a rare issue considering how long I’ve been using the plugin.
  • There has been at least one case where renaming a brush would cause a “crash” on startup on the next Krita session, but the plugin will go about its business anyway after that, so it doesn’t seem major.
  • Unlike ThreeSlots this plugin doesn’t save brush size, but it’s a fairly minor problem in my case that I can work around.
  • The shortcuts can’t be used when a group layer is activated. I would prefer not having that restriction, as it’s jarring when it does nothing.
  • Minor suggestion: When the user picks a color while on the “Eraser tool”, it should automatically switch back to the “Brush tool”.