images property

List<VtImage> get images

The images on the screen, top to bottom, each where it is: the rectangle around the cells it still has.

Implementation

List<VtImage> get images {
  final found = <VtImage>[];
  final seen = Set<VtImage>.identity();
  for (var y = 0; y < height; y++) {
    for (var x = 0; x < width; x++) {
      final c = _grid[y][x];
      for (final image in [c.kitty, c.image]) {
        if (image == null) {
          continue;
        }
        if (seen.add(image)) {
          found.add(
            image
              ..x = x
              ..y = y
              ..cols = 1
              ..rows = 1
              ..cells = 0,
          );
        }
        if (x < image.x) {
          image
            ..cols += image.x - x
            ..x = x;
        }
        image
          ..cols = x - image.x + 1 > image.cols ? x - image.x + 1 : image.cols
          ..rows = y - image.y + 1
          ..cells += 1;
      }
    }
  }
  return found;
}