Bug 251610

Summary: Lines drawn quickly, start looking "bent" rather than smooth
Product: [Applications] krita Reporter: Kubuntiac <user581>
Component: ToolsAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: cberger, goffrie, halla, lukast.dev, pentalis
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Showing two lines drawn at different speeds, with different smoothness
Patch to change smoothing
Make la
Image showing line smoothing improvements and remaining issue

Description Kubuntiac 2010-09-17 21:04:51 UTC
Version:           svn trunk (using KDE 4.5.1) 
OS:                Linux

When lines are painted slowly and carefully on a tablet, they come out looking smooth and as expected. If painting quickly (even with a small brush) they become more like a set of sraight lines with sharper bends in them.

If this is something like not enough sample data from the driver, then maybe we could increase smoothing with cursor velocity?

Reproducible: Always

Steps to Reproduce:
1. Paint a continuous line rapidly. (Such as a scribble)

Actual Results:  
A line made of straight parts with bends.

Expected Results:  
One continuous curvy line.

OS: Linux (i686) release 2.6.32-24-generic-pae
Compiler: cc
Revision:1176447
Driver:ATI Foss driver
Kubuntu Lucid (10.04)
Comment 1 Kubuntiac 2010-09-17 21:06:56 UTC
Created attachment 51764 [details]
Showing two lines drawn at different speeds, with different smoothness
Comment 2 Halla Rempt 2010-10-29 11:13:07 UTC
SVN commit 1190958 by rempt:

add a return statement after fatal to please gcc 4.5.1

BUG:251610

 M  +3 -0      KoCtlCompositeOp.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1190958
Comment 3 Halla Rempt 2010-11-06 15:01:13 UTC
Yes, definitely the case.
Comment 4 Geoffry Song 2011-03-16 04:54:24 UTC
Here's a patch that changes the smoothing method. It uses cardinal splines (https://secure.wikimedia.org/wikipedia/en/wiki/Cardinal_spline#Cardinal_spline), so at every mouse event, it only knows enough to draw the the curve up to the *previous* mouse event. It does complete the curve on mouse release. I still respect the 'smoothness' parameter, but it seems a bit useless - decreasing it from 1000 makes curves less smooth, which kind of defeats the purpose of the feature...

On a more mundane note, I don't like the name 'm_olderPaintInformation' (which is one step older than 'm_previousPaintInformation') but I couldn't think of anything better.
Comment 5 Geoffry Song 2011-03-16 04:55:03 UTC
Created attachment 58072 [details]
Patch to change smoothing
Comment 6 Kubuntiac 2011-03-16 06:13:27 UTC
Thanks! Is this in trunk, or does it need to be manually applied?
Comment 7 Geoffry Song 2011-03-16 06:17:30 UTC
You'll have to apply it yourself. I hope it works for you :)
Comment 8 Halla Rempt 2011-03-16 08:21:37 UTC
Cool stuff, I'll try it today.
Comment 9 Halla Rempt 2011-03-17 09:57:10 UTC
Okay. I definitely see an improvement, so it's worth going in, though it's not perfect yet, but that might be my cheap graphire graphics tablet. The whole smoothness setting is something we need to discuss. Cyrille, what do you think?
Comment 10 Cyrille Berger 2011-03-18 13:56:24 UTC
Since you said it is improveming, please commit.
Comment 11 Halla Rempt 2011-03-18 17:49:56 UTC
Geoffry, can you commit yourself or do you want to get a kde committer account?
Comment 12 Geoffry Song 2011-03-18 18:02:05 UTC
I don't have commit access. How do I get a committer account?
Comment 13 Halla Rempt 2011-03-18 18:09:38 UTC
Follow the instructions on http://techbase.kde.org/Contribute/Get_a_SVN_Account, giving me as your sponsor.
Comment 14 LukasT 2011-03-19 14:55:20 UTC
My opinion about this patch was that is should be optional.
It had disadvantage that you see your stroke one dab behind.
It is not always what I want when I paint.
Comment 15 Geoffry Song 2011-03-19 15:13:59 UTC
Well, unchecking the 'smooth' checkbox does disable it.
Comment 16 LukasT 2011-03-19 16:28:44 UTC
Sure, but the bezier way of smoothing is still useful and does not have the disadvantage of being one dab behind.

So I would like to have no smooth lines, smooth lines with bezier, smooth line with cubics.
Comment 17 Geoffry Song 2011-03-20 22:04:58 UTC
I'm curious as to when this is an issue (the stroke being a dab behind). I only notice this effect occasionally, when making a very rapid movement and then immediately stopping, which seems a bit artificial to me. If it really is important, then maybe an extra node should be added if the mouse stops moving for a short while?

I just don't think it makes sense to have an option of "not smooth", "less smooth" or "smooth". In particular, the old code, although it does produce a smooth curve, really creates a series of question-mark shaped curves (bump on one end and a straight line on the other), and I don't think that makes sense in any situation.


btw: a cubic spline is a Bezier curve :)
Comment 18 Geoffry Song 2011-03-22 23:18:19 UTC
Created attachment 58265 [details]
Make la
Comment 19 Geoffry Song 2011-03-22 23:20:25 UTC
Whoops, I hit Enter by accident. That last patch adds a timer to make lag less noticeable by finishing the stroke to the latest mouse position after 100ms of inactivity, creating a 'cusp' (i.e. not smooth) but it should make lag less noticeable.

It applies on top of the previous patch.
Comment 20 Geoffry Song 2011-03-22 23:50:16 UTC
Git commit fadd748ee43a830e1e15e577330b8d21e30c9a3f by Geoffry Song.
Committed on 16/03/2011 at 04:43.
Pushed by geoffrysong into branch 'master'.

Smooth freehand tool with cardinal splines

This creates smoother curves when drawing quickly (when there are few mouse
events).

CCBUG:251610

M  +21   -12   krita/ui/tool/kis_tool_freehand.cc     
M  +1    -0    krita/ui/tool/kis_tool_freehand.h     

http://commits.kde.org/calligra/fadd748ee43a830e1e15e577330b8d21e30c9a3f
Comment 21 Sven Langkamp 2011-06-07 19:45:36 UTC
*** Bug 273861 has been marked as a duplicate of this bug. ***
Comment 22 Halla Rempt 2011-06-07 19:55:48 UTC
I committed a revert of a56c0ab64ca1290b034e863439319d38daddefab ("Let dirty rect to be a QRegion instead of a QRect") which once again makes the lines buttery smooth for me.
Comment 23 Kubuntiac 2011-07-08 20:40:13 UTC
Created attachment 61714 [details]
Image showing line smoothing improvements and remaining issue

At the moment I'd say this looks about 75% better. I checked in mypaint and that have some of this issue as well, although not quite as pronounced as it was in Krita when I filed this bug. Now I'd say we look slightly better. :)

I'm still having circular curves be "flattened" often, but this may well be another issue. I've attached an image that oth shows where things look better, and the issue I'm still having.

On a side note, text shapes are acting very weird for me. As you'll see in the image, they're outputting an image like they're selected *even to the exported image*. No this image is not a screen capture. Anyway, that's *definitely* another issue, but I'm just mentioning it here, in case this image makes you wonder.
Comment 24 Geoffry Song 2011-07-08 21:02:15 UTC
I also get that (using a mouse btw), but only when OpenGL is enabled - with it disabled, everything is nice and smooth.
Comment 25 Halla Rempt 2011-08-02 08:53:55 UTC
Geoffry -- the two patches attached have been committed, right?
Comment 26 Geoffry Song 2011-08-02 16:27:38 UTC
Yes, they have.
Comment 27 Halla Rempt 2011-08-02 17:08:42 UTC
Comment on attachment 58072 [details]
Patch to change smoothing

submitted
Comment 28 Halla Rempt 2011-08-02 17:08:56 UTC
Comment on attachment 58265 [details]
Make la

submitted
Comment 29 Halla Rempt 2011-08-02 17:09:31 UTC
Great, then I'll mark the patches as obsolete so ths doesn't show up when searching for bug reports with patches.
Comment 30 Halla Rempt 2011-10-16 14:01:54 UTC
With the new strokes framework, all lines come out smooth and nice for me, even if Krita cannot keep up with my input.