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);
x = transform.x(x);
y = transform.y(y);
x = canvasX(x);
y = canvasY(y);
width = canvasX(width);
height = canvasY(height);
final imageWidth = image.width;
final imageHeight = image.height;
if (image is _PCanvasImageElement) {
if (width == imageWidth && height == imageHeight) {
_ctx.drawImage(image.imageElement, x, y);
} else {
_ctx.drawImageScaled(image.imageElement, x, y, width, height);
}
} else {
throw ArgumentError("Can't handle image type: $image");
}
}