Skip to content

Commit 9160151

Browse files
committed
Fix ImageInterpolationEx scene and increase height in ImageInterpolation test
1 parent 06a4fb8 commit 9160151

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

manim/mobject/types/image_mobject.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,18 @@ def construct(self):
155155
[0, 0, 0, 255]
156156
]))
157157
158-
img.height = 2
159-
img1 = img.copy()
160-
img2 = img.copy()
161-
img3 = img.copy()
162-
img4 = img.copy()
163-
img5 = img.copy()
164-
165-
img1.set_resampling_algorithm(RESAMPLING_ALGORITHMS["nearest"])
166-
img2.set_resampling_algorithm(RESAMPLING_ALGORITHMS["lanczos"])
167-
img3.set_resampling_algorithm(RESAMPLING_ALGORITHMS["linear"])
168-
img4.set_resampling_algorithm(RESAMPLING_ALGORITHMS["cubic"])
169-
img5.set_resampling_algorithm(RESAMPLING_ALGORITHMS["box"])
170-
img1.add(Text("nearest").scale(0.5).next_to(img1,UP))
171-
img2.add(Text("lanczos").scale(0.5).next_to(img2,UP))
172-
img3.add(Text("linear").scale(0.5).next_to(img3,UP))
173-
img4.add(Text("cubic").scale(0.5).next_to(img4,UP))
174-
img5.add(Text("box").scale(0.5).next_to(img5,UP))
175-
176-
x= Group(img1,img2,img3,img4,img5)
177-
x.arrange()
178-
self.add(x)
158+
img.height = 3
159+
160+
group = Group()
161+
algorithm_texts = ["nearest", "linear", "cubic"]
162+
for algorithm_text in algorithm_texts:
163+
algorithm = RESAMPLING_ALGORITHMS[algorithm_text]
164+
img_copy = img.copy().set_resampling_algorithm(algorithm)
165+
img_copy.add(Text(algorithm_text).scale(0.5).next_to(img_copy, UP))
166+
group.add(img_copy)
167+
168+
group.arrange()
169+
self.add(group)
179170
"""
180171

181172
def __init__(

tests/test_graphical_units/test_img_and_svg.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,14 @@ def test_ImageInterpolation(scene):
268268
img = ImageMobject(
269269
np.uint8([[63, 0, 0, 0], [0, 127, 0, 0], [0, 0, 191, 0], [0, 0, 0, 255]]),
270270
)
271-
img.height = 2
271+
img.height = 3
272272

273-
algorithms = ["nearest", "bilinear", "bicubic"]
274-
for pos, algorithm in enumerate(algorithms):
275-
algorithm = RESAMPLING_ALGORITHMS[algorithm]
273+
algorithm_texts = ["nearest", "linear", "cubic"]
274+
for i, algorithm_text in enumerate(algorithms):
275+
algorithm = RESAMPLING_ALGORITHMS[algorithm_text]
276276
img_copy = img.copy().set_resampling_algorithm(algorithm)
277-
img_copy.shift((2 * pos - len(algorithms) + 1) * RIGHT)
277+
position = img.height * (i - (len(algorithm_texts) - 1) / 2) * RIGHT
278+
img_copy.move_to(position)
278279
scene.add(img_copy)
279280

280281
scene.wait()

0 commit comments

Comments
 (0)