code: def get_tile_from_image(image, size, top_left_corner, tile_size):
      
      tile_pixels = []
      # crop tile if necessary
      tile_x = min(size[0] - top_left_corner[0], tile_size[0])
      tile_y = min(size[1] - top_left_corner[1], tile_size[1])
      tile_size = tile_x, tile_y
      for y in range(tile_size[1]):
          for x in range(tile_size[0]):
              coords = (x + top_left_corner[0], y + top_left_corner[1])
              tile_pixels.append(image[coords_to_index(coords, size[0])])
      return tile_pixels, tile_size
docs: Returns a rectangular region of the given image as a separate image
      If the tile goes off the edge of the image, it will be truncated. The new size is also returned.
      :param image: The given image, as a list of (R,G,B) tuples
      :param size: The size of the image, as (width, height)
      :param top_left_corner: The top left corner of the tile, relative to the image, as a tuple (x,y)
      :param tile_size: The size of the tile, as a tuple (width, height)
      :return: A tuple (tile, size) where the tile is a list of (R,G,B) tuples and the size is (width, height)