rotateColumn method

void rotateColumn(
  1. Rect bounds,
  2. int colIndex,
  3. int amount
)

Rotates a specific column within the given bounds by amount downward.

Implementation

void rotateColumn(Rect bounds, int colIndex, int amount) {
  if (colIndex < 0 || colIndex >= bounds.width) return;
  if (bounds.height <= 1) return;
  amount = amount % bounds.height;
  if (amount < 0) amount += bounds.height;
  if (amount == 0) return;

  final x = bounds.x + colIndex;
  if (x < 0 || x >= width) return;

  final n = bounds.height;
  _reverseCol(x, bounds.y, 0, n - 1);
  _reverseCol(x, bounds.y, 0, amount - 1);
  _reverseCol(x, bounds.y, amount, n - 1);
}