Formatted cursor scaler

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-09-02 01:16:02 +02:00
parent 2caad7ad5a
commit 3ad9efcf77
+10 -6
View File
@@ -39,11 +39,15 @@ class CursorScaler {
int hotspotY,
double size,
) async {
final capped = size > _maxSize ? _maxSize.toDouble() : size;
if (image.width == capped && image.height == capped) {
return Cursor(image: image, hotspotX: hotspotX, hotspotY: hotspotY);
final double capped = size >= _maxSize ? _maxSize.toDouble() : size;
if (image.width == capped || image.height == capped) {
return Cursor(
image: image,
hotspotX: hotspotX,
hotspotY: hotspotY,
);
}
final ratio = capped / image.width;
final double ratio = capped / image.width;
return _scale(image, hotspotX, hotspotY, ratio);
}
@@ -76,8 +80,8 @@ class CursorScaler {
int hotspotY,
double ratio,
) async {
final width = (image.width * ratio).round();
final height = (image.height * ratio).round();
final int width = (((image.width * ratio) + 4) ~/ 8) * 8;
final int height = (((image.height * ratio) + 4) ~/ 8) * 8;
final recorder = ui.PictureRecorder();
final canvas = ui.Canvas(recorder);
canvas.scale(ratio, ratio);