tileBounds method

Vector4 tileBounds(
  1. int index
)

The atlas-space UV box of tile index's content area as (minU, minV, maxU, maxV), inset past the padding gutter so sampling stays inside the tile. Tiles are row-major with a top-left origin.

Implementation

Vector4 tileBounds(int index) {
  assert(index >= 0 && index < tileCount);
  final col = index % columns;
  final row = index ~/ columns;
  final x0 = col * _cellSize + padding;
  final y0 = row * _cellSize + padding;
  final w = width.toDouble();
  final h = height.toDouble();
  return Vector4(x0 / w, y0 / h, (x0 + tileSize) / w, (y0 + tileSize) / h);
}