getFrameCount method

int getFrameCount(
  1. int textureWidth,
  2. int textureHeight
)

Implementation

int getFrameCount(int textureWidth, int textureHeight) {
  if (frameCount != null) return frameCount!;

  final effectiveFrameWidth = frameWidth + paddingX;
  final effectiveFrameHeight = frameHeight + paddingY;

  if (maxColumns != null) {
    // grid mode with wrapping
    final availableWidth = textureWidth - offsetX;
    final availableHeight = textureHeight - offsetY;
    final cols = availableWidth ~/ effectiveFrameWidth;
    final rows = availableHeight ~/ effectiveFrameHeight;
    return cols * rows;
  } else {
    // single row mode
    final availableWidth = textureWidth - offsetX;
    return availableWidth ~/ effectiveFrameWidth;
  }
}