getFrameRect method

RectangleD getFrameRect(
  1. int frameIndex
)

Implementation

RectangleD getFrameRect(int frameIndex) {
  if (maxColumns != null) {
    final col = frameIndex % maxColumns!;
    final row = startRow + (frameIndex ~/ maxColumns!);

    return .rect(
      (offsetX + col * (frameWidth + paddingX)),
      (offsetY + row * (frameHeight + paddingY)),
      frameWidth,
      frameHeight,
    );
  } else {
    return .rect(
      (offsetX + frameIndex * (frameWidth + paddingX)),
      (offsetY + startRow * frameHeight),
      frameWidth,
      frameHeight,
    );
  }
}