class_docstr: Class that generates one or more sprite atlases.
class_docstr_tok: ["Class","that","generates","one","or","more","sprite","atlases","."]
docstr: Returns a single sprite atlas
docstr_tok: ["Returns","a","single","sprite","atlas"]
code: def _create_single_atlas(self):
      """Returns a single sprite atlas"""
      (atlas_width, atlas_height) = self._generate_default_atlas_size()
  
      # Initialize manifest
      manifest = []
  
      # Ensure they're ints
      atlas_width = int(atlas_width)
      atlas_height = int(atlas_height)
  
      # Atlas size in pixels (width, height)
      atlas_size_pixels = (
          atlas_width * self._img_width_height_px[0],
          atlas_height * self._img_width_height_px[1],
      )
      logging.debug(
          "generating atlas of size %d, %d"
          % (atlas_size_pixels[0], atlas_size_pixels[1])
      )
  
      # We create a background image of the atlas size that we will paste the
      # sprite images onto.
      montage = Image.new(
          "RGBA", atlas_size_pixels, (255, 255, 255, 255)
      )
      # Generate row by row, from left to right, top to bottom.
      image_idx = 0
      failed_images_count = 0
      for row_idx in range(0, atlas_width):
          offset_height = row_idx * self._img_width_height_px[1]
          for col_idx in range(0, atlas_height):
              if image_idx >= self._num_input_images:
                  # Finished montaging all images.
                  break
              offset_width = col_idx * self._img_width_height_px[0]
  
              # Manifest entry for that image.
              img_manifest = {
                  MANIFEST_IMAGE_NAME_KEY: os.path.basename(
                      self._img_src_paths[image_idx]
                  ),
                  MANIFEST_SOURCE_IMAGE_KEY: self._img_src_paths[
                      image_idx
                  ],
                  MANIFEST_OFFSET_X_KEY: offset_width,
                  MANIFEST_OFFSET_Y_KEY: offset_height,
              }
  
              img = self._images_with_statuses[image_idx][0]
              status = self._images_with_statuses[image_idx][1]
              if img is not None:
                  montage.paste(img, (offset_width, offset_height))
              else:
                  montage.paste(
                      self._default_image, (offset_width, offset_height)
                  )
                  failed_images_count += 1
                  # Add error message to manifest.
                  img_manifest[MANIFEST_IMAGE_FAIL_KEY] = status
              manifest.append(img_manifest)
              image_idx += 1
  
      logging.info(
          "Montaged %d images onto sprite atlas of size %s "
          "pixels." % (image_idx, str(atlas_size_pixels))
      )
      if failed_images_count > 0:
          logging.warning(
              "%d images had failures and were replaced by the default "
              "image" % failed_images_count
          )
      return montage, manifest
  
imports: import math
  import os
  from absl import logging
  from PIL import Image
label_desc: Use image node_id 5 for calling the SpriteAtlasGenerator obj's underlying member method code with example usage: obj._create_single_atlas() and returns: montage,  manifest