Fix dotted brushstrokes when drawing with semitransparent colors#942
Conversation
…ransparent colors
|
Thanks for looking at this! |
|
@cameronwhite Thanks! I'll be looking into that soon |
|
Thanks, the ToolLayer approach looks better 👍 Some notes from doing a bit more testing:
|
|
Hi @cameronwhite, I just pushed a few commits that deals with the issues above:
|
I think this was because the base class OnMouseDown() calls the OnMouseMove handler to avoid dealing with single-click as a special case ( Pinta/Pinta.Tools/Tools/BaseBrushTool.cs Line 75 in 35c2d7f So a better fix would be to move the ToolLayer.Clear() / ToolLayer.Hidden = false before calling base.OnMouseDown() in the paintbrush tool
I think the behaviour looks okay when dragging to draw a line, but doing just a single click produces some odd asymmetric antialiasing which you can see in the screenshot. The old behaviour produced a "plus" shape which I think would be more expected for that scenario Otherwise, the changes are looking good! |
|
Thanks for telling me, @cameronwhite |
|
Looks good, thanks for contributing! |

This PR deals with issue #941.
Why the issue happens:
Each line segment of the stroke in the PlainBrush is drawn independently, one after another. With semitransparent colors, the line segments overlap each other on their ends, causing the dark dots in the stroke.
How this PR solves it:
Upon
OnMouseDown(), we create a Cairo Path variable calledpathas a class member, set it to null, and show the ToolLayer.During
OnMouseMove()events, we operate on the ToolLayer surface and clear it before drawing (we only clear for the PlainBrush), appendpathto the cairo context and after stroking, copy the new path back to the class member. Cairo will draw the entire path in one go, which gets rid of the dark dots. Performance hit is negligible.In
OnMouseUp()we draw the contents of the ToolLayer onto the destination Layer, clear and hide it.The Pencil Tool isn't affected by this PR.
Paint strokes before and after applying the PR:
