fix(cursor): align Web hotspots with rounded cursor images

This commit is contained in:
fufesou
2026-09-12 03:29:27 +08:00
parent d876ea0ce4
commit 96cd5cd1e2
3 changed files with 85 additions and 6 deletions

View File

@@ -2920,8 +2920,8 @@ class CursorData {
img2.encodePng(
img2.copyResize(
image,
width: (width * scale).toInt(),
height: (height * scale).toInt(),
width: isWeb ? (width * scale).round() : (width * scale).toInt(),
height: isWeb ? (height * scale).round() : (height * scale).toInt(),
interpolation: img2.Interpolation.average,
),
),
@@ -2932,6 +2932,11 @@ class CursorData {
this.scale = scale;
hotx = hotxOrigin * scale;
hoty = hotyOrigin * scale;
if (isWeb) {
// CSS hotspots must follow the actual rounded PNG dimensions.
hotx = hotxOrigin * (width * scale).round() / width;
hoty = hotyOrigin * (height * scale).round() / height;
}
return scale;
}