diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index a39bc7d08..1c7c6cafa 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -696,6 +696,8 @@ class CursorData { final img2.Image? image; double scale; Uint8List? data; + final double hotxOrigin; + final double hotyOrigin; double hotx; double hoty; final int width; @@ -707,11 +709,12 @@ class CursorData { required this.image, required this.scale, required this.data, - required this.hotx, - required this.hoty, + required this.hotxOrigin, + required this.hotyOrigin, required this.width, required this.height, - }); + }) : hotx = hotxOrigin * scale, + hoty = hotxOrigin * scale; int _doubleToInt(double v) => (v * 10e6).round().toInt(); @@ -731,16 +734,14 @@ class CursorData { image!, width: (width * scale).toInt(), height: (height * scale).toInt(), + interpolation: img2.Interpolation.cubic, ) .getBytes(format: img2.Format.bgra); } } this.scale = scale; - if (hotx > 0 && hoty > 0) { - // default cursor data - hotx = (width * scale) / 2; - hoty = (height * scale) / 2; - } + hotx = hotxOrigin * scale; + hoty = hotyOrigin * scale; return scale; } @@ -811,8 +812,6 @@ class CursorModel with ChangeNotifier { if (_defaultCache == null) { Uint8List data; double scale = 1.0; - double hotx = (defaultCursorImage!.width * scale) / 2; - double hoty = (defaultCursorImage!.height * scale) / 2; if (Platform.isWindows) { data = defaultCursorImage!.getBytes(format: img2.Format.bgra); } else { @@ -825,8 +824,8 @@ class CursorModel with ChangeNotifier { image: defaultCursorImage?.clone(), scale: scale, data: data, - hotx: hotx, - hoty: hoty, + hotxOrigin: defaultCursorImage!.width / 2, + hotyOrigin: defaultCursorImage!.height / 2, width: defaultCursorImage!.width, height: defaultCursorImage!.height, ); @@ -996,10 +995,8 @@ class CursorModel with ChangeNotifier { image: Platform.isWindows ? img2.Image.fromBytes(w, h, data) : null, scale: 1.0, data: data, - hotx: 0, - hoty: 0, - // hotx: _hotx, - // hoty: _hoty, + hotxOrigin: _hotx, + hotyOrigin: _hoty, width: w, height: h, );