GSoC/2022/StatusReports/XuChe

From KDE Community Wiki
< GSoC‎ | 2022‎ | StatusReports

Pixel-perfect ellipses

Currently, Krita can't draw pixel-perfect ellipses, this is due to the error introduced by using Bezier curves and straight lines to approximate an ellipse. This project aims to make specialised algorithms that work pixel-perfect for common shapes like ellipses. This project also proposes other improvements for pixel art creation.

Work report

Not too much technical detail is here, for more details, see my blog and the MR page.

Adding an extended midpoint algorithm

The midpoint algorithm is a specialised algorithm for painting ellipses, but the most commonly seen implementation does not handle rotation, I implemented an extended version of the midpoint algorithm which supports rotation in Krita. Also, I implemented a pixel-perfect filter which can make a stroke pixel-perfect by removing pixels on the L-shape vertex. I believe this pixel-perfect filter can also be repurposed for freehand tools or other uses.

Redirect ellipse tool to new code

I inspected all call sites of the old non-pixel-perfect code, and rewrite all the draw calls to the new pixel-perfect version. I'm still preserving the old code now. The old code will be removed once I confirmed the replacement is full and complete.

Filling and spacing support

I have to implement filling support for ellipses, which can be foreground colour filling, background colour filling, pattern filling and no filling. There also should be support for dab spacing control. I converted the resulting ellipse into an array of pixel points and treated them as a polygon, by reusing the code for drawing a polygon, I supported features like filling and spacing.

Documentition and tests

Since this project is a fix to the old ellipse tool and introduced no new feature, so no user-facing documentation was added, but I added a detailed explanation in the code to show my intentions and reasons, especially I wrote some blog posts and detailed comments on how the core algorithm works. I also added unit tests for precision and functions like filling and spacing.

22/06/20: The ellipse algorithm is mainly done but lacks tests and needs improvements.

22/07/25: The most updates before midterm evaluation are in my blog here: https://blog.xuche.ml/post/gsoc-update-draw-ellipses-in-krita/

for any updates after, please consult my blog page and the MR page.

Links

MRs:

Issue tracker:

My blog for GSoC: