zoomed_scene¶
支持放大指定区域的场景。
示例
示例:使用缩放场景 ¶
from manim import *
class UseZoomedScene(ZoomedScene):
def construct(self):
dot = Dot().set_color(GREEN)
self.add(dot)
self.wait(1)
self.activate_zooming(animate=False)
self.wait(1)
self.play(dot.animate.shift(LEFT))
class UseZoomedScene(ZoomedScene):
def construct(self):
dot = Dot().set_color(GREEN)
self.add(dot)
self.wait(1)
self.activate_zooming(animate=False)
self.wait(1)
self.play(dot.animate.shift(LEFT))
示例:更改缩放比例 ¶
from manim import *
class ChangingZoomScale(ZoomedScene):
def __init__(self, **kwargs):
ZoomedScene.__init__(
self,
zoom_factor=0.3,
zoomed_display_height=1,
zoomed_display_width=3,
image_frame_stroke_width=20,
zoomed_camera_config={
"default_frame_stroke_width": 3,
},
**kwargs
)
def construct(self):
dot = Dot().set_color(GREEN)
sq = Circle(fill_opacity=1, radius=0.2).next_to(dot, RIGHT)
self.add(dot, sq)
self.wait(1)
self.activate_zooming(animate=False)
self.wait(1)
self.play(dot.animate.shift(LEFT * 0.3))
self.play(self.zoomed_camera.frame.animate.scale(4))
self.play(self.zoomed_camera.frame.animate.shift(0.5 * DOWN))
class ChangingZoomScale(ZoomedScene):
def __init__(self, **kwargs):
ZoomedScene.__init__(
self,
zoom_factor=0.3,
zoomed_display_height=1,
zoomed_display_width=3,
image_frame_stroke_width=20,
zoomed_camera_config={
"default_frame_stroke_width": 3,
},
**kwargs
)
def construct(self):
dot = Dot().set_color(GREEN)
sq = Circle(fill_opacity=1, radius=0.2).next_to(dot, RIGHT)
self.add(dot, sq)
self.wait(1)
self.activate_zooming(animate=False)
self.wait(1)
self.play(dot.animate.shift(LEFT * 0.3))
self.play(self.zoomed_camera.frame.animate.scale(4))
self.play(self.zoomed_camera.frame.animate.shift(0.5 * DOWN))
类
这是一个具有特殊配置的场景,用于当场景的某个特定部分需要放大并单独显示时。 |