Feature: Color Picker Blending

Authored by emmetoneill on Apr 3 2018, 1:37 AM.



This patch adds new 'blending' functionality to the color picker (both the dedicated tool and the ctrl-activated one) along with the associated "blend" slider to the color picker's tool options GUI.

Inspired by traditional painting, color picker blending changes the way that color pickers have traditionally worked in Krita and other similar digital art programs; instead of completely replacing the user's current brush color with a newly sampled color for a given pixel or radius, color picker blending allows the picker to act more like a physical brush or sponge by "soaking up" some portion of sampled color (based on the "blend" option slider) and mixing it into the user's brush color. In practice, this gives artists another convenient way to mix colors "off canvas", independent of brush shape, opacity, and stroke location. This feature can also be used in combination with other classic digital painting techniques like semi-transparent glossing or smudge mixing for, in my biased opinion, great results and a very paint-like feel.

It's worth noting that, as of now, the color picker seems to "resample" as the user moves their mouse around - this is a mixed blessing. With a relatively low blend value it can feel great to "dip" you color picker into a color and drag it around as it picks up more and more color, but with a higher blend value it can sometimes be easy to sample more color than you intended to, especially when using a drawing tablet as it can be easy to make small movements when you tap your pen against the surface. This is a minor issue and can be mitigated by being careful or using lower blend values when using a tablet, but a future "fix" could involve slowing down the rate at which the color picker "resamples" as you drag it around with some kind of timer or leniency area.

I put together a small and informal demo video: (Sorry for the audio quality issues).
Krita Feature Prototype - Color Picker Blending
Krita Color Picker Blending Prototype Feature - Demo Painting Timelapse (No Audio)

Finally. I'd also like to mention that I created this feature patch together with my brother and friend Eoin, and for both of us this is our first patch submission to an open source project! What better project than Krita?

Test Plan

Test both the dedicated color picker and "ctrl-picker" (for both foreground and background colors), using mouse input and tablets at various "blend" settings (Color Picker > Tool Options > Blend Slider) for predictable and desirable behavior in a variety of colorspaces.

Diff Detail

R37 Krita
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
emmetoneill created this revision.Apr 3 2018, 1:37 AM
emmetoneill created this object with edit policy "emmetoneill (Emmet O'Neill)".
Restricted Application added a subscriber: woltherav. ยท View Herald TranscriptApr 3 2018, 1:37 AM
emmetoneill requested review of this revision.Apr 3 2018, 1:37 AM
emmetoneill edited the summary of this revision. (Show Details)Apr 3 2018, 1:41 AM
emmetoneill edited the test plan for this revision. (Show Details)
rempt added a comment.Apr 3 2018, 6:20 AM

Nice work! The patch works as advertised :-)


I'd use a KisSliderSpinBox here, and make the user-visible range go from 0..100 instead of 0..255.

rempt added a comment.Apr 4 2018, 7:31 AM

If you can update it to use the smarter slider, I can push the patch for you!

emmetoneill updated this revision to Diff 31351.EditedApr 5 2018, 5:10 AM

Changed the 0..255 QSlider to a 0..100 KisSliderSpinBox and made some necessary changes to the blending code.

Organized the color picker's options panel, also adding (I think) artist-friendly tool tips.

Cleaned up the code style as much as possible and removed lots of unused #includes (replacing with forward declarations where possible). kis_tools_colorpicker.cc really needed that spring cleaning! =]

emmetoneill edited the summary of this revision. (Show Details)Apr 5 2018, 5:16 AM
rempt added a comment.Apr 5 2018, 7:07 AM

I'm afraid the patch no longer applies to -- I get a conflict in plugins/tools/basictools/kis_tool_colorpicker.cc:

patching file plugins/tools/basictools/kis_tool_colorpicker.cc
Hunk #2 FAILED at 20.
Hunk #3 succeeded at 85 (offset 3 lines).
Hunk #4 succeeded at 107 (offset 3 lines).
Hunk #5 succeeded at 117 with fuzz 2 (offset 3 lines).
Hunk #6 FAILED at 126.
Hunk #7 FAILED at 136.
Hunk #8 FAILED at 161.
Hunk #9 FAILED at 170.
Hunk #10 succeeded at 225 (offset 21 lines).
Hunk #11 succeeded at 256 (offset 21 lines).
Hunk #12 succeeded at 265 (offset 21 lines).
Hunk #13 succeeded at 317 (offset 21 lines).
Hunk #14 succeeded at 328 (offset 21 lines).
Hunk #15 succeeded at 360 (offset 21 lines).
Hunk #16 succeeded at 396 (offset 21 lines).
5 out of 16 hunks FAILED -- saving rejects to file plugins/tools/basictools/kis_tool_colorpicker.cc.rej

I haven't got time to resolve that manually right now, have to leave in 20 minutes.

I see. I've tried pulling master again and merging my color picker branch locally to see if I can help out at all.

Assuming we're seeing the same thing, from what I can tell:

[Conflict 1 line 26-38] I stripped away a bunch of unused (at the time of my branch, at least) #includes. From a glance it looks like it should still be fine to remove them.

[Conflict 2 line 117-157] Code related to sampling radius, the HEAD's code should be fine.

[Conflict 3 line 180-187] Basically the same.

[Conflict 4 line 194-217] Blending stuff, should be fine to take my code? The blending stuff basically just sits between the radius code and setting the foreground/background color.

Sorry about the extra work, let me know if there is any way for me to help!

@emmetoneill I would just update your diff on this task and resubmit it. That's the easiest way to do things if the patch doesn't apply because of more recent code changes.

@emmetoneill I would just update your diff on this task and resubmit it. That's the easiest way to do things if the patch doesn't apply because of more recent code changes.

Ok. I'll give that a try!

emmetoneill updated this revision to Diff 31418.EditedApr 5 2018, 6:37 PM

This should fix the merge conflict. Thanks everyone for bearing with me as I've been learning a lot about how all of this works. =]

This revision was not accepted when it landed; it landed in state Needs Review.Apr 6 2018, 8:52 AM
This revision was automatically updated to reflect the committed changes.