def make_frame(t):
     wallclock = ((t / duration_sec)**time_warp) * times[-1]
     png, kimg, lod = snaps[max(bisect.bisect(times, wallclock) - 1, 0)]
     if png_cache[0] == png:
         img = png_cache[1]
     else:
         img = scipy.misc.imread(png)
         while img.shape[1] > 1920 or img.shape[0] > 1080:
             img = (img.astype(np.float32).reshape(img.shape[0] // 2, 2,
                                                   img.shape[1] // 2, 2,
                                                   -1).mean(axis=(1, 3)))
         png_cache[:] = [png, img]
     img = misc.draw_text_label(img,
                                "lod %.2f" % lod,
                                16,
                                img.shape[0] - 4,
                                alignx=0.0,
                                aligny=1.0)
     img = misc.draw_text_label(
         img,
         misc.format_time(int(np.rint(wallclock))),
         img.shape[1] // 2,
         img.shape[0] - 4,
         alignx=0.5,
         aligny=1.0,
     )
     img = misc.draw_text_label(
         img,
         "%.0f kimg" % kimg,
         img.shape[1] - 16,
         img.shape[0] - 4,
         alignx=1.0,
         aligny=1.0,
     )
     return img
 def make_frame(t):
     wallclock = ((t / duration_sec) ** time_warp) * times[-1]
     png, kimg, lod = snaps[max(bisect.bisect(times, wallclock) - 1, 0)]
     if png_cache[0] == png:
         img = png_cache[1]
     else:
         img = scipy.misc.imread(png)
         while img.shape[1] > 1920 or img.shape[0] > 1080:
             img = img.astype(np.float32).reshape(img.shape[0]//2, 2, img.shape[1]//2, 2, -1).mean(axis=(1,3))
         png_cache[:] = [png, img]
     img = misc.draw_text_label(img, 'lod %.2f' % lod, 16, img.shape[0]-4, alignx=0.0, aligny=1.0)
     img = misc.draw_text_label(img, misc.format_time(int(np.rint(wallclock))), img.shape[1]//2, img.shape[0]-4, alignx=0.5, aligny=1.0)
     img = misc.draw_text_label(img, '%.0f kimg' % kimg, img.shape[1]-16, img.shape[0]-4, alignx=1.0, aligny=1.0)
     return img
 def make_frame(t):
     wallclock = ((t / duration_sec) ** time_warp) * times[-1]
     png, kimg, lod = snaps[max(bisect.bisect(times, wallclock) - 1, 0)]
     if png_cache[0] == png:
         img = png_cache[1]
     else:
         img = scipy.misc.imread(png)
         # Check if the img is greyscale. If so, it needs to be converted to RGB, since MoviePy expects it in that format
         if img.ndim == 2:
             tmpimg = img
             img = np.zeros([tmpimg.shape[0], tmpimg.shape[1], 3], tmpimg.dtype)
             img[:,:,0] = tmpimg
             img[:,:,1] = tmpimg
             img[:,:,2] = tmpimg
         while img.shape[1] > 1920 or img.shape[0] > 1080:
             img = img.astype(np.float32).reshape(img.shape[0]//2, 2, img.shape[1]//2, 2, -1).mean(axis=(1,3))
         png_cache[:] = [png, img]
     img = misc.draw_text_label(img, 'lod %.2f' % lod, 16, img.shape[0]-4, alignx=0.0, aligny=1.0)
     img = misc.draw_text_label(img, misc.format_time(int(np.rint(wallclock))), img.shape[1]//2, img.shape[0]-4, alignx=0.5, aligny=1.0)
     img = misc.draw_text_label(img, '%.0f kimg' % kimg, img.shape[1]-16, img.shape[0]-4, alignx=1.0, aligny=1.0)
     return img