-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Copy link
Labels
issue:bugSomething isn't working... For use in issuesSomething isn't working... For use in issues
Description
Description of bug / unexpected behavior
Attempting to flip a ImageMobject
across an axis does not seem to behave correctly. Flipping across the UP
axis acts the same as a 180° rotation, while flipping across the RIGHT
axis does nothing.
How to reproduce the issue
class Main(Scene):
def construct(self):
imgs = [ImageMobject("thinking.png").scale(0.1) for i in range(4)]
self.add(Group(
imgs[0],
imgs[1].flip(),
imgs[2].rotate(PI, UP),
imgs[3].apply_matrix([[-1, 0], [0, 1]])
).arrange(RIGHT))
Additional media files
Additional comments
The only way I have figured out to flip images across a single axis so far is to edit the pixel array like so:
img.pixel_array = np.fliplr(img.pixel_array) # for horizontal
img.pixel_array = np.flipud(img.pixel_array) # for vertical
Metadata
Metadata
Assignees
Labels
issue:bugSomething isn't working... For use in issuesSomething isn't working... For use in issues
Type
Projects
Status
🆕 New
Activity
behackl commentedon Jan 5, 2022
Just looked into this a bit. The proper way of fixing this would be to adapt the implementation in
Camera.display_image_mobject
-- basically,ImageMobject
s are placed by specifying the coordinates of the upper left, upper right, and lower left corner (inImageMobject.points
). Manim is able to handle the case where the lower left corner is higher than the upper right corner (i.e., a flip along the horizontal axis), but curiously not when the upper right corner is left of the upper left corner (vertical flip).hennels commentedon Mar 15, 2022
I believe the problem mentioned by @behackl also occurs frequently in
ThreeDScene
s and leads to a rather comical effect. When an image is part of aThreeDScene
the flipping happens naturally during rotations causing the image to distort and flip wildly.hennels commentedon Apr 28, 2022
I believe this issue was fixed for the OpenGL renderer with #2534 as seen below. The distortion shown above and the flipping issue mentioned earlier seem to work now when OpenGL is used. The issues still exist with Cairo.
[-]Flipping does not work as expected for ImageMobject[/-][+]3D rotating and flipping does not work as expected for `ImageMobject`[/+]ImageMobject
3D rotation/flipping and remove resampling algorithmslanczos
(antialias
),box
andhamming
#4266