calculateScaleFactor method
_ScaleFactor
calculateScaleFactor(
- Size viewBox
)
Implementation
_ScaleFactor calculateScaleFactor(Size viewBox) {
//Scale factors
double dx = (viewBox.width) / this.pathBoundingBox.width;
double dy = (viewBox.height) / this.pathBoundingBox.height;
//Applied scale factors
late double ddx, ddy;
//No viewport available
assert(!(dx == 0 && dy == 0));
//Case 1: Both width/height is specified or MediaQuery
if (!viewBox.isEmpty) {
if (this.customDimensions != null) {
//Custom width/height
ddx = dx;
ddy = dy;
} else {
ddx = ddy = min(dx, dy); //Maintain resolution and viewport
}
//Case 2: CustomDimensions specifying only one side
} else if (dx == 0) {
ddx = ddy = dy;
} else if (dy == 0) {
ddx = ddy = dx;
}
return _ScaleFactor(ddx, ddy);
}