slint icon indicating copy to clipboard operation
slint copied to clipboard

Path {} blurs straight lines

Open george-hopkins opened this issue 1 year ago • 2 comments

I'm trying to render two lines, each 1px wide, separated by a 1px gap:

Path {
    commands: "M 0 0 h 1 v 50 h -1 z m 2 0 h 1 v 50 h -1 z";
    fill: black;
    height: 50px;
    width: 50px;
}

1x Magnified 10x (height: 500px): 10x The magnified version shows crisp edges, however the black bars are still too wide (12px instead of 10px) and the gap is only 8px wide. Is there a setting to tweak this behaviour?

george-hopkins avatar Dec 09 '23 09:12 george-hopkins

I wonder if perhaps what you're seeing is anti-aliasing "quality".

I made a test-case like this:

export component Testcase inherits Window {
    preferred-width: 300px; preferred-height: 300px;

     Path {
         commands: "M 0 0 h 1 v 50 h -1 z m 2 0 h 1 v 50 h -1 z";
         fill: black;
         height: 50px;
         width: 50px;
     }
}

and this is the rendering I get on macOS:

With the FemtoVG renderer:

Screenshot 2023-12-18 at 10 05 54

With Skia (Metal):

Screenshot 2023-12-18 at 10 06 55

With Skia (OpenGL):

Screenshot 2023-12-18 at 10 10 45

With Qt:

Screenshot 2023-12-18 at 10 11 19

In a way it's unlikely that they'd all look identical, but on the other hand the FemtoVG result stands out by what looks like an anti-aliasing effect.

If I explicitly disable anti-aliasing I get a better result:

Screenshot 2023-12-18 at 10 12 52

I pushed the branch to https://github.com/slint-ui/slint/commits/simon/path-antialias-option/ .

However the screenshot you posted shows a bad width, instead of a surrounding shade of grey.

Could you try with different renderers? That would help us isolate things a little. Also, perhaps you could try the above branch and add an anti-alias: false; to the Path and see if that improves the rendering for you.

tronical avatar Dec 18 '23 09:12 tronical

Thank you for the detailed analysis! The anti-alias option does fix the issue indeed. The lines end up crisp and distinguishable. It would be great if this addition could be integrated into the main version.

george-hopkins avatar Apr 03 '24 09:04 george-hopkins