diff --git a/manim/camera/camera.py b/manim/camera/camera.py index b26e4aec0e..4e64163110 100644 --- a/manim/camera/camera.py +++ b/manim/camera/camera.py @@ -966,7 +966,7 @@ def display_image_mobject( The Pixel array to put the imagemobject in. """ corner_coords = self.points_to_pixel_coords(image_mobject, image_mobject.points) - ul_coords, ur_coords, dl_coords = corner_coords + ul_coords, ur_coords, dl_coords, _ = corner_coords right_vect = ur_coords - ul_coords down_vect = dl_coords - ul_coords center_coords = ul_coords + (right_vect + down_vect) / 2 diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.py index 5cefb1ac93..cb0248d3a5 100644 --- a/manim/mobject/types/image_mobject.py +++ b/manim/mobject/types/image_mobject.py @@ -86,12 +86,13 @@ def set_resampling_algorithm(self, resampling_algorithm: int): return self def reset_points(self): - # Corresponding corners of image are fixed to these 3 points + """Sets :attr:`points` to be the four image corners.""" self.points = np.array( [ UP + LEFT, UP + RIGHT, DOWN + LEFT, + DOWN + RIGHT, ], ) self.center() diff --git a/tests/test_graphical_units/test_img_and_svg.py b/tests/test_graphical_units/test_img_and_svg.py index b234431abb..b2ae820cb6 100644 --- a/tests/test_graphical_units/test_img_and_svg.py +++ b/tests/test_graphical_units/test_img_and_svg.py @@ -284,3 +284,20 @@ def test_ImageInterpolation(scene): scene.add(img1, img2, img3, img4, img5) [s.shift(4 * LEFT + pos * 2 * RIGHT) for pos, s in enumerate(scene.mobjects)] scene.wait() + + +def test_ImageMobject_points_length(): + file_path = get_svg_resource("tree_img_640x351.png") + im1 = ImageMobject(file_path) + assert len(im1.points) == 4 + + +def test_ImageMobject_rotation(): + # see https://github.com/ManimCommunity/manim/issues/3067 + # rotating an image to and from the same angle should not change the image + file_path = get_svg_resource("tree_img_640x351.png") + im1 = ImageMobject(file_path) + im2 = im1.copy() + im1.rotate(PI / 2) + im1.rotate(-PI / 2) + np.testing.assert_array_equal(im1.points, im2.points)