Bug 499696

Summary: Half-pixel aligned mirror tool sometimes broken
Product: [Applications] krita Reporter: ricardojorge512+kde
Component: ToolsAssignee: Krita Bugs <krita-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: giga-zoddom
Priority: NOR    
Version First Reported In: 5.2.9   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Showing that a larger brush size can only mirror right halves of pixels.

Description ricardojorge512+kde 2025-02-08 20:02:08 UTC
SUMMARY
Pixel lines are not correctly mirrored with half-pixel aligned mirroring tool.

STEPS TO REPRODUCE
1. Create an odd-sized small image (ex: 7x7)
2. Select a pixel drawing brush
3. Zoom in and place the cursor on the left side of the mirroring tool
4. Click on the left half of a pixel

OBSERVED RESULT
Only the pixel under the cursor is painted.

EXPECTED RESULT
Another pixel should have appeared, mirrored on the right side.

SOFTWARE/OS VERSIONS
Linux: Gentoo
Krita: AppImage 5.2.9 (git ac6cae8)

ADDITIONAL INFORMATION
Also, the line tool is broken. I suspect there is some shenanigans regarding rounding up or rounding down when converting the mouse position (which is sub-pixel aligned), into the pixel index to actually paint, but can't be sure.
Comment 1 ricardojorge512+kde 2025-02-08 20:03:03 UTC
Forgot to mention a step between 1 and 2: "Activate the vertical mirroring tool".
Comment 2 Lukas 2025-05-15 14:51:46 UTC
Reproduced and confirmed this on Windows 10.

I have included a video that also confirms which part of a subpixel you paint is important. 

As seen in the video, if your brush size is more than 1px (in this case 1.5px), you can paint 2 pixels at a time, but only the one that is "touched" by the cursor on its right half will get mirrored.

One correction to the initial description: the canvas resolution doesnt matter, it depends on here you place the mirror. This bug only happens if the mirror is placed in the center of a subpixel, similar to this bug: https://bugs.kde.org/show_bug.cgi?id=502855

Possibly some could have something to do with the subpixel coordinates with a subpixel-mirror. 
I will try to test this further in the coming week.
Comment 3 Lukas 2025-05-15 14:56:45 UTC
Created attachment 181339 [details]
Showing that a larger brush size can only mirror right halves of pixels.