getShiftedOuterLoopProgressor method

double getShiftedOuterLoopProgressor(
  1. double shapeDimension,
  2. double spaceBetweenShapes
)

Used as the loop incrementor for the outer loop of the calculations for drawing shapes with the ScrollerShapeOffset.shift and ScrollerShapeOffset.shiftAndMesh arrangement.

shapeDimension is the width or height of the shape depending on the ScrollDirection. Width in the case of horizontal (left/right) scrolling and height in the case of vertical (up/down) scrolling.

Implementation

double getShiftedOuterLoopProgressor(
  double shapeDimension,
  double spaceBetweenShapes,
) {
  if (identical(data.shapeOffset, ScrollerShapeOffset.shiftAndMesh)) {
    // a^2 + b^2 = c^2
    // b^2 = c^2 - a^2
    // c = shapeWidth
    // a = shapeWidth / 2
    // b = sqrt(c^2 - a^2)
    final double b =
        sqrt(pow(shapeDimension, 2) - pow(shapeDimension / 2, 2));
    return (shapeDimension - (shapeDimension - b)) + spaceBetweenShapes;
  } else {
    return shapeDimension + spaceBetweenShapes;
  }
}