scaleCanvasToViewBox method

void scaleCanvasToViewBox(
  1. Canvas canvas,
  2. Size desiredSize
)

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) {
  render_picture.scaleCanvasToViewBox(
    canvas,
    desiredSize,
    viewport.viewBoxRect,
    viewport.size,
  );
}