Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic smoothing of hand-drawn lines #194

Closed
pascal-niklaus opened this issue Feb 26, 2024 · 2 comments
Closed

Automatic smoothing of hand-drawn lines #194

pascal-niklaus opened this issue Feb 26, 2024 · 2 comments

Comments

@pascal-niklaus
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Hand-drawn lines often look shaky...

Describe the solution you'd like

...applying some smoothing algorithm can clean-up such lines

Possible solution

Since I have been playing with the gromit source code, I have also implemented a smoothing option.

Basically, when a line is completed, it first applies a point reduction using the Douglas-Peucker algorithm, and then interpolates among the remaining points with centripetal Catmull-Rom splines.

The general shape and start and end points are preserved, and the smoothing degree can be set.

Here is an example with relatively strong smoothing.

gromit_smoothing

Before spamming this repo with PRs, I wanted to discuss (1) whether such an option is useful, and, if yes, (2) how it is best integrated. For the moment, I just have an additional tool called SMOOTH, but there could be a "smooth=..." option for the PEN tool.

To provide a perspective on the extent of code addition, the entire smoothing logic is a bit less than 200 lines of code, in an additional file smooth.c.

@bk138
Copy link
Owner

bk138 commented Mar 2, 2024

@pascal-niklaus Neat idea! Sorry for the delay, I was busy with €€€-work. I guess a separate tool aka GromitPaintContext makes sense as the smoothing is not applicable to ERASER, RECOLOR OR LINE. Maybe call it SMOOTH_PEN ?

@bk138
Copy link
Owner

bk138 commented Mar 29, 2024

Implemented by 19a5569

@bk138 bk138 closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants