drawImageScaled method
Draw an image
at (x
,y
) scaling it to the dimension width
x height
.
Implementation
@override
void drawImageScaled(
PCanvasImage image, num x, num y, num width, num height) {
checkImageLoaded(image);
if (image is! _PCanvasImageFlutter) {
throw ArgumentError(
"Can't handle image type `${image.runtimeType}`: $image");
}
var xd = transform.xD(x);
var yd = transform.yD(y);
xd = canvasXD(xd);
yd = canvasYD(yd);
final widthD = canvasXD(width);
final heightD = canvasYD(height);
final rect1 =
Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble());
final rect2 = Rect.fromLTWH(xd, yd, widthD, heightD);
_widgetPainter.addOp((canvas, size) {
var paint = Paint();
canvas.drawImageRect(image.flutterImage, rect1, rect2, paint);
});
}