@@ -973,15 +973,25 @@ def display_image_mobject(
973
973
The pixel array to put the :class:`~.ImageMobject` in.
974
974
"""
975
975
sub_image = Image .fromarray (image_mobject .get_pixel_array (), mode = "RGBA" )
976
+
977
+ # PIL's image corner ordering is:
978
+ # - UL (Up Left)
979
+ # - DL (Down Left)
980
+ # - DR (Down Right)
981
+ # - UR (Up Right)
982
+ # Respect this order to reduce floating point error.
976
983
original_coords = np .array (
977
984
[
978
- [0 , 0 ],
979
- [sub_image . width , 0 ],
980
- [0 , sub_image .height ],
981
- [sub_image .width , sub_image . height ],
985
+ [0 , 0 ], # UL corner
986
+ [0 , sub_image . height ], # DL corner
987
+ [sub_image . width , sub_image .height ], # DR corner
988
+ [sub_image .width , 0 ], # UR corner
982
989
]
983
990
)
984
- target_coords = self .points_to_pixel_coords (image_mobject , image_mobject .points )
991
+ # ImageMobject corners are in a different order and must be reordered.
992
+ ul_corner , ur_corner , dl_corner , dr_corner = image_mobject .points
993
+ reordered_points = [ul_corner , dl_corner , dr_corner , ur_corner ]
994
+ target_coords = self .points_to_pixel_coords (image_mobject , reordered_points )
985
995
986
996
# Temporarily translate target coords to upper left corner to calculate the
987
997
# smallest possible size for the target image.
0 commit comments