Skip to content

Python Extension: Mutator

Emmet O'Neill requested to merge emmetoneill/krita:PyEx-Mutator into master

Mutator

A python extension for Krita which adds brush variation through action-invoked settings randomization.

Includes

  • New action "Mutate", which when invoked by the artist causes their brush settings to be randomly changed within some user-configurable range.
  • New docker "Mutator", where the various mutation settings live.

Screenshot_From_2025-02-05_19-25-20

(The painting above makes heavy use of occasional brush/color mutations by occasionally invoking the "Mutate" action, which I bound to the "z" key on my keyboard. You can see the [default] mutation settings used for each parameter in the "Mutator" Docker, along with an extra GUI button for invoking the mutate action. By just hitting "z" (or whatever you have the action bound to) every one in a while, you can easy get very natural and painterly color and brush variations, and I think it's a lot of fun to play around with too!)

Motivation

One of the things that makes physical media so nice looking is the subtle and natural variation that comes from working with real tools and materials--your brush doesn't ever create the same stroke twice, and it's almost impossible to mix the exact same color (with the exact same hue, saturation, value and opacity) twice. In the context of digital painting, clean, predictable and flat colors are kind of the default, and so we need to work harder to create the kinds of nuances that come naturally in physical media.

Of course, Krita's existing per-dab and per-stroke brush randomization settings are already pretty good tools for adding these kinds of dynamics. But, the randomization that they add happens at a very predictable cadence: every dab of the brush tip and every stroke of the brush, respectively. This kind of randomness is still useful for certain effects, but it isn't exactly connected to what the artist in front of the computer is doing.

That's where the Mutator extension comes in. The goals are two-fold: (1) slow down the frequency of brush variations to a more "natural" cadence, like you might get by occasionally bringing your brush over to your palette in physical media, and (2) put the artist in direct control of the mutations invocation.

(@eoinoneill and I actually roughed in this plugin way back in 2018 for our own use, and I've finally gotten around to updating and hopefully upstreaming it now.)

Immediate Plans (I'd like to do these before merging)

  • Pick a default keybind for the "Mutate" action. (I really like "z" for this, since I'm a lefty and it's right under my right ring finger when I paint. I also like having it close to the color picker and the switch fg/bg color keys.)
  • Replace the QSliders with our custom DoubleSpinBoxSlider widgets. (They look better and are much easier to use, but I can't seem to get them to work through python, so I'm guessing the classes aren't properly exposed in the API yet.)
  • Create documentation.

Future Ideas (Probably not blockers)

  • Per-stroke auto-mutate chance. (I'd like to add a slider that adds a probability for mutations to automatically occur after each stroke. For example, setting the probably to 10% would create a 10% chance that any stroke might automatically cause a mutation.)
  • Per-sample auto-mutate chance. (Just like the per-stroke chance. I'd like to add an option where using the Eyedropper Tool to sample colors from the canvas has a chance to automatically cause a mutation to happen.)
  • Brush-specific mutation settings. (Instead of having a bunch of global mutation settings in the Mutator docker, we could have mutation settings exist in the BrushOp resources, so that difference brushes could mutate in different ways! I'm not sure yet if this is possible under the current Python scripting API or if this is something that would need to be done in C++, but I think it's an interesting future direction for this concept that would put a lot of new power in the hands of brush authors.)

Testing

  • Make sure "Mutator" is active in Settings>Configure Krita>Python Plugin Manager.
  • Restart Krita
  • Open the "Mutator" docker from Settings>Dockers.
  • Set the various parameters to whatever mutation values you want. (The defaults should be a good starting point.)
  • Bind the "Mutate" action to a key (I can recommend "z", at least for lefties) in Settings>Configure Krita>Keyboard Shortcuts.
  • Paint some stuff, mutate, paint more, mutate again, and so on!

Give it a try and let me know how you like it. :)

Edited by Emmet O'Neill

Merge request reports

Loading