Skip to content

"Semi-video" image option for testing and previewing a scene #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kolibril13 opened this issue Dec 8, 2020 · 1 comment
Closed

"Semi-video" image option for testing and previewing a scene #849

kolibril13 opened this issue Dec 8, 2020 · 1 comment
Labels
enhancement Additions and improvements in general

Comments

@kolibril13
Copy link
Member

I have an idea to overlay videoframes from certain timestamps above each other, e.g. from this scene:

from manim import *

class ABC(Scene):
    def construct(self):
        sq = Circle().set_color(YELLOW_C).shift(4*LEFT).scale(0.6)
        self.add(sq)
        rec = Square().shift(4*RIGHT).scale(0.6).set_fill("#87CEEB",1)
        self.play(Transform(sq,rec),run_time=3)
        self.wait(1)

ABC

Which can be converted into this:
image
to create this specific example, I used the script you can see at the bottom.
This is only a first prototype but in a more advanced approach, one could further include parameters how many frames will be overlaid, what the time interval will be, and further, it would be nice to make the latter images higher opacity than to the former images.
This can be a very useful tool for creating manim scenes, without the necessity to see the video, but to have the time projection into two dimensions, and further, it could be a great addition for our test section, as we do not yet support video testing.
A starting point to implement this could be something like this:

nums_of_steps= 4
for timestemp in np.linspace(0,2,nums_of_steps):
    image += scene.renderer.get_frame(pos= timestemp) #does not exist yet

And here the prototype code for the above image example:

import numpy as np
import matplotlib.pyplot as plt
url="/home//Downloads/pngs/"
from imageio import imread
image = np.array(imread(url+ "ABC0.png"))
image += np.array(imread(url+ "ABC80.png"))
image += np.array(imread(url+ "ABC100.png"))
image += np.array(imread(url+ "ABC210.png"))
plt.axis('off')
plt.imshow(image, interpolation='nearest', cmap='gray')
plt.show()
@kolibril13 kolibril13 added the enhancement Additions and improvements in general label Dec 8, 2020
@eulertour
Copy link
Member

I actually don't think there are many uses for this. It'd be an imprecise and difficult-to-debug way to implement video tests and won't be useful for scenes where mobjects transform in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additions and improvements in general
Projects
None yet
Development

No branches or pull requests

2 participants