缩放场景¶
一个支持对指定部分进行缩放的场景。
示例
示例: UseZoomedScene ¶
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))
示例: ChangingZoomScale ¶
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))
类
这是一个特殊的场景,配置用于当场景的特定部分需要被放大并单独显示时。 |