Skip to content
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

Allow add two or more ImageMobjects and TextureSurfaces #2055

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

germanzhu
Copy link

Motivation

Adding two or more images with ImageMobject showing the recent image in the Scene.

The same problem also occurs in TextureSurface, and this PR is meant to solve this problem.

Proposed changes

  • image_mobject.py
  • surface.py
  • shader_wrapper.py

Test

Code:

from manimlib import *


class Video(Scene):
    
    def construct(self):
        
        image_file1 = "resources/barter-1.png"
        image_file2 = "resources/measure.png"
        image_file3 = "resources/Thales.jpg"
        image_file4 = "resources/Oheaviside.jpg"
        
        im1 = ImageMobject(image_file1)
        im2 = ImageMobject(image_file2)
        
        im1.set_width(3)
        im2.set_width(3)
        
        self.play(FadeIn(im1))
        self.play(im1.animate.shift(3*LEFT))
        
        self.play(FadeIn(im2))
        self.play(im2.animate.shift(3*RIGHT))
        
        
        surf1 = Sphere(radius=1)
        surf2 = Sphere(radius=1)
        
        surf2.move_to(np.array([2,3,1]))
        
        ts1 = TexturedSurface(surf1,image_file3)
        ts2 = TexturedSurface(surf2,image_file4)
        self.play(ShowCreation(ts1))
        self.play(ShowCreation(ts2))
        
        frame = self.camera.frame
        frame.set_euler_angles(
            theta=-30 * DEGREES,
            phi=70 * DEGREES,
        )
        
        frame.add_updater(lambda m, dt: m.increment_theta(-0.1 * dt))
        self.wait(5)

Result:

Video.mp4

@bengioe
Copy link

bengioe commented Oct 18, 2023

FWIW applying this patch solved another problem for me where when rendering multiple images some erroneous textured triangles would appear between images (as if the batching went wrong within OpenGL).

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

Successfully merging this pull request may close these issues.

None yet

2 participants