Formatted cursor scaler
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -39,11 +39,15 @@ class CursorScaler {
|
|||||||
int hotspotY,
|
int hotspotY,
|
||||||
double size,
|
double size,
|
||||||
) async {
|
) async {
|
||||||
final capped = size > _maxSize ? _maxSize.toDouble() : size;
|
final double capped = size >= _maxSize ? _maxSize.toDouble() : size;
|
||||||
if (image.width == capped && image.height == capped) {
|
if (image.width == capped || image.height == capped) {
|
||||||
return Cursor(image: image, hotspotX: hotspotX, hotspotY: hotspotY);
|
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);
|
return _scale(image, hotspotX, hotspotY, ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +80,8 @@ class CursorScaler {
|
|||||||
int hotspotY,
|
int hotspotY,
|
||||||
double ratio,
|
double ratio,
|
||||||
) async {
|
) async {
|
||||||
final width = (image.width * ratio).round();
|
final int width = (((image.width * ratio) + 4) ~/ 8) * 8;
|
||||||
final height = (image.height * ratio).round();
|
final int height = (((image.height * ratio) + 4) ~/ 8) * 8;
|
||||||
final recorder = ui.PictureRecorder();
|
final recorder = ui.PictureRecorder();
|
||||||
final canvas = ui.Canvas(recorder);
|
final canvas = ui.Canvas(recorder);
|
||||||
canvas.scale(ratio, ratio);
|
canvas.scale(ratio, ratio);
|
||||||
|
|||||||
Reference in New Issue
Block a user