resizeShapesAlongHeight method
This is used to resize the shapes and the space between the shapes to fit the screen width perfectly and proportionally.
This is done because if the original shapeSize.height
+
spaceBetweenShapes
is not a factor of the screen height, then the shapes
will not fit the screen height perfectly. The will be too close together
or too far apart at the beginning and end of the loop. The measurements
remain very close to the original measurements.
It returns a map:
{
MeasurementName.shapeHeight: newShapeHeight,
MeasurementName.shapeWeight: newShapeWeight,
MeasurementName.spaceBetweenShapes: newSpaceBetweenShapes,
}
Implementation
Map<MeasurementName, double> resizeShapesAlongHeight(
Size shapeSize,
double spaceBetweenShapes,
Size canvasSize,
) {
final double shapeWidthAndHeightProportion =
shapeSize.width / shapeSize.height;
final Map<MeasurementName, double> resizedMeasurements = _resizeShapes(
shapeSize.height,
spaceBetweenShapes,
canvasSize.height,
MeasurementName.shapeHeight,
);
final double newShapeHeight =
resizedMeasurements[MeasurementName.shapeHeight] ?? shapeSize.height;
resizedMeasurements[MeasurementName.shapeWidth] =
newShapeHeight * shapeWidthAndHeightProportion;
return resizedMeasurements;
}