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,
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user