I’m trying draw Hard Grid using Skia on a 1920x1080 screen.
I am encountering inconsistent sharpness when drawing thin lines.
Space: PixelTopLeft (using WithinPhysicalScreenSpace)
I drew three test lines with different StrokeWidths:
0.1 & 0.3: The lines appear blurry and faint (grayish).
0.2: This one appears sharp/ideal in my test.
My questions:
Why does 0.2 look sharp while others blur? Is this a sub-pixel alignment artifact?Is this due to my Skia line width settings or anti-aliasing settings?
What is the best practice to get a perfect, solid 1px hard line?
For drawing a UI-style hard grid (with fully covered pixels, no antialiasing/blending) in PixelTopLeft space using Skia, what would be the recommended approach?
With my current Line + Stroke setup, is it better to disable antialiasing o’r pixel-snap the coordinates? Is there have setting?
@joreg Emmm…I understand… the problem I’m having isn’t entirely about drawing 1-pixel lines. it’s a fundamental pixel sampling and rendering pipeline issue, but I haven’t found a good solution yet…
I’ve constrained the animation values.
Specifically, I constrained the Float32 data to two decimal places, resulting in a completely smooth animation.
However, I still haven’t found a better way to achieve a more perfect effect. For example, when the line stroke width ends in an odd number, the lines appear grayish and the edges are blurry.
When the line width ends in an odd number, I offset the position coordinates by 0.5px, and it appeared sharper. In terms of layout, it basically meets my needs.