docs: def capture(cb, pool, params):
      """
      Renders and saves a screen-sized picture of the current position.
  
      :param cb: Cursebox instance.
      :type cb: cursebox.Cursebox
      :param params: Current application parameters.
      :type params: params.Params
      """
      w, h = screen_resolution()
  
      # Re-adapt dimensions to match current plane ratio
      old_ratio = w / h
      new_ratio = params.plane_ratio
      if old_ratio > new_ratio:
          w = int(h * new_ratio)
      else:
          h = int(w / new_ratio)
  
      image = Image.new("RGB", (w, h), "white")
      pixels = image.load()
  
      # FIXME: refactor common code to get_palette(params)
      palette = PALETTES[params.palette][1]
      if params.reverse_palette:
          palette = palette[::-1]
  
      # All coordinates to be computed as single arguments for processes
      coords = [(x, y, w, h, params) for x in range(w) for y in range(h)]
  
      results = []
      # Dispatch work to pool and draw results as they come in
      for i, result in enumerate(pool.imap_unordered(compute_capture, coords, chunksize=256)):
          results.append(result)
          if i % 2000 == 0:
              draw_progress_bar(cb, "Capturing current scene...", i, w * h)
              cb.refresh()
  
      min_value = 0.0
      max_value = params.max_iterations
      max_iterations = params.max_iterations
  
      if params.adaptive_palette:
          from operator import itemgetter
          min_value = min(results, key=itemgetter(2))[2]
          max_value = max(results, key=itemgetter(2))[2]
  
      # Draw pixels
      for result in results:
          value = result[2]
          if params.adaptive_palette:
              # Remap values from (min_value, max_value) to (0, max_iterations)
              if max_value - min_value > 0:
                  value = ((value - min_value) / (max_value - min_value)) * max_iterations
              else:
                  value = max_iterations
          pixels[result[0], result[1]] = get_color(value, params.max_iterations, palette)
  
      if not os.path.exists("captures/"):
          os.makedirs("captures/")
  
      ts = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d_%H-%M-%S")
      filename = "captures/almonds_%s.png" % ts
      image.save(filename, "PNG")
      params.log("Current scene captured!")
      params.log("(Used %d processes)" % pool._processes)
  
      open_file(filename)