code: def get_tile_images_by_rect(self, rect):
          def rev(seq, start, stop):
              if start < 0:
                  start = 0
              return enumerate(seq[start:stop + 1], start)
          x1, y1, x2, y2 = rect_to_bb(rect)
          images = self.tmx.images
          layers = self.tmx.layers
          at = self._animated_tile
          tracked_gids = self._tracked_gids
          anim_map = self._animation_map
          track = bool(self._animation_queue)
          for l in self.tmx.visible_tile_layers:
              for y, row in rev(layers[l].data, y1, y2):
                  for x, gid in [i for i in rev(row, x1, x2) if i[1]]:
                      if track and gid in tracked_gids:
                          anim_map[gid].positions.add((x, y, l))
                      try:
                          yield x, y, l, at[(x, y, l)]
                      except KeyError:
                          yield x, y, l, images[gid]