scaleCanvasToViewBox method
Scales the canvas
so that the drawing units in this Drawable
will scale to the desiredSize
.
If the viewBox
dimensions are not 1:1 with desiredSize
, will scale to
the smaller dimension and translate to center the image along the larger
dimension.
Implementation
void scaleCanvasToViewBox(Canvas canvas, Size desiredSize) {
final Matrix4 transform = Matrix4.identity();
if (render_picture.scaleCanvasToViewBox(
transform,
desiredSize,
viewport.viewBoxRect,
viewport.size,
)) {
canvas.transform(transform.storage);
}
}