Krita/Brush Color Transformation

From KDE Community Wiki

Lukáš Tvrdý is working on this: Digital Painters pick color of the brush quite often and it has to be quick. At least Paul Haeberli is talking about this as put-this-color-there procedure.

Through my time with paintops I came to some transformations that can be useful. So far I have this features:

HSV transformation

  • I would like user to allow select interval like -20 to 20 for Hue, Saturation and Value separately. So far user can select 0..x or -x..0 interval :/ I do not have GUI element ready for it.

I saw some widget on planet kde from some kde games guy which looked like it would fit. During stroke random number is generated and current color is trasformated according that.

Random opacity

  • Random number is generated and alpha of the color is set to that number. Again some interval like 80%-100% would be cool.

Sample input color

  • So far rawData or oldRawData is fetched with kis_random_subaccessor from the current layer you paint on and the color is then used as color for particle (spray, grid brush).

For future user should be able to select read layer. So far current layer is used.

Mix colors

  • background and foreground colors are mixed based on the pressure from the tablet or if mouse is used,random number is used (interval would be cool again)

I want to make ink depletion more general. It is implemented in sumi-e so far, but every brush can use it. User define the amount of ink (sumi's default is 1024) and every call of paintAt/paintLine counter is updated and the value of HSV or opacity is decreased or increased. Curve is used to determine how fast or how much the color is decreased/increased.

Fill background

  • used by grid brush, fills the particle background with background color.

Color per particle

  • Some paintops (grid, spray) can do color transformatio per particle, so this is just checkbox

I would like to share the GUI dialogs between the paintops. But sometimes not every GUI element can be implemented by the paintop. E.g. fill background. I don't know if there is something like inheritance between UI files (I suppose there is not), but maybe hidding the elements could work (like set visible to false)

You can mix some options together in the GUI.

E.g. you can sample the input color, then the color is transformed with HSV or opacity etc. This part is still in development as I do this for my thesis.


Cyrille Berger had dynamic brush in Krita and he take away principle called sensors. The implementation can be found at this files: libpaintop/sensors/

  • KisDynamicSensorFuzzy: returns random number in 0.0..1.0
  • KisDynamicSensorSpeed: returns 1.0 + 10% of the size of the movement in one step
  • KisDynamicDrawingAngle: returns something I'm not able to describe, but it computes angle (altough angle is already computed in KisPaintInformation)

Cyrille's IRC note: if I remember corectly angle() from mouvement is always equal to {0, 45, 90, 135, ... } (or that use to be like that), while KisDynamicDrawingAngle give a smoother angle

  • KisDynamicSensorPressure: returns info.pressure()
  • KisDynamicSensorXTilt: returns x-tilt in 0.0..1.0 (converted from KisPaintInformation which uses [-60,60] interval)
  • KisDynamicSensorYTilt: returns y-tilt in 0.0..1.0 (converted from KisPaintInformation which uses [-60,60] interval)

libpaintop/sensors/ provides:

  • KisDynamicSensorTime

in fact it is more "path integral" according Cyrille, it has nothing with time The math is explained here But in a complicated way.

libpaintop/ is the base class for sensors.

Other related classes: