Draft for Information Only
Content
Mobject Resizing def scale(self, scale_factor, **kwargs) def scale_in_place(self, scale_factor, **kwargs) def scale_about_point(self, scale_factor, point) def stretch(self, factor, dim, **kwargs) def stretch_about_point(self, factor, dim, point) def stretch_in_place(self, factor, dim) def rescale_to_fit(self, length, dim, stretch=False, **kwargs) def stretch_to_fit_width(self, width, **kwargs) def stretch_to_fit_height(self, height, **kwargs) def stretch_to_fit_depth(self, depth, **kwargs) def set_width(self, width, stretch=False, **kwargs) def set_height(self, height, stretch=False, **kwargs) def set_depth(self, depth, stretch=False, **kwargs) Example Code Output
Mobject
The defined resizing functions for Mobject in mobject.py
- def scale(self, scale_factor, **kwargs)
- def scale_in_place(self, scale_factor, **kwargs)
- def scale_about_point(self, scale_factor, point)
- def stretch(self, factor, dim, **kwargs)
- def stretch_about_point(self, factor, dim, point)
- def stretch_in_place(self, factor, dim)
- def rescale_to_fit(self, length, dim, stretch=False, **kwargs)
- def stretch_to_fit_width(self, width, **kwargs)
- def stretch_to_fit_height(self, height, **kwargs)
- def stretch_to_fit_depth(self, depth, **kwargs)
- def set_width(self, width, stretch=False, **kwargs)
- def set_height(self, height, stretch=False, **kwargs)
- def set_depth(self, depth, stretch=False, **kwargs)
Resizing
def scale(self, scale_factor, **kwargs)
scale is used to scale a Mobject about the center of the Mobject by the specified scale_factor parameter, scale_factor, according to the specified parameters.
def scale_in_place(self, scale_factor, **kwargs)
stretch is used to scale a Mobject about the center of the Mobject by the specified scale_factor parameter, scale_factor, according to the specified parameters.
def scale_about_point(self, scale_factor, point)
stretch is used to scale a Mobject about the specified point parameter, point, by the specified scale_factor parameter, scale_factor, according to the specified parameters.
def stretch(self, factor, dim, **kwargs)
stretch is used to stretch a Mobject about the point parameter, point by the specified factor parameter, factor, with respect to the specified dim parameter, dim, according to the specified parameters.
def stretch_about_point(self, factor, dim, point)
stretch_about_point is used to stretch a Mobject about the specified point parameter, point, by the specified factor parameter, factor, with respect to the specified dim parameter, dim, according to the specified parameters.
def stretch_in_place(self, factor, dim)
stretch_in_place is used to stretch a Mobject about the center of the Mobject by the specified factor parameter, factor, with respect to the specified dim parameter, dim, according to the specified parameters.
def rescale_to_fit(self, length, dim, stretch=False, **kwargs)
rescale_to_fit is used to rescale a Mobject to fit the specified length parameter, length, with respect to the specified dim parameter, dim, according to the specified parameters.
def stretch_to_fit_width(self, width, **kwargs)
stretch_to_fit_width is used to stretch the width of a Mobject to fit the specified width parameter, width, according to the specified parameters.
def stretch_to_fit_height(self, height, **kwargs)
stretch_to_fit_height is used to stretch the height of a Mobject to fit the specified height parameter, height, according to the specified parameters.
def stretch_to_fit_depth(self, depth, **kwargs)
stretch_to_fit_depth is used to stretch the depth of a Mobject to fit the specified depth parameter, depth, according to the specified parameters.
def set_width(self, width, stretch=False, **kwargs)
set_width is used to rescale a Mobject to fit the specified width parameter, width, with respect to the width of the Mobject according to the specified parameters.
def set_height(self, height, stretch=False, **kwargs)
set_height is used to rescale a Mobject to fit the specified height parameter, height, with respect to the height of the Mobject according to the specified parameters.
def set_depth(self, depth, stretch=False, **kwargs)
set_depth is used to rescale a Mobject to fit the specified depth parameter, depth, with respect to the depth of the Mobject according to the specified parameters.
Example
Code
# folder/file: tut/manim_mobject_func_resizing_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Rectangle, Square, Circle, Line,RoundedRectangle
from manimlib.animation.creation import ShowCreation
from manimlib.mobject.svg.tex_mobject import TexMobject, TextMobject
from manimlib.animation.fading import FadeOut
from manimlib.animation.creation import Write
from manimlib.animation.transform import ApplyMethod, ApplyFunction
class manim_mobject_func_resizing_001a(Scene):
def construct(self):
linex=Line([2,2,0],[1,1,0],color="#88FF00")
polya= RoundedRectangle(width=2,height=2,corner_radius=0.5,stroke_width=0,fill_color="#FFFF00",fill_opacity=1)
polyb = Rectangle(width=2.5,height=1.5,stroke_width=15,color="#88FF00",fill_color="#FFFF00",fill_opacity=1)
polyc= Square(side_length=2,stroke_width=20,fill_color="#FF8800",fill_opacity=1).move_to([-3,-2,0])
polyd= Circle(arc_center=(-2,0.75,0),color="#888888")
polya.add(Rectangle(width=2,height=2,color="#77DDCC").move_to(polya))
polya.add(Rectangle(width=1,height=2.5,color="#77DDCC").move_to(polya))
polya.add(TextMobject("A").move_to(polya))
polye = Rectangle(width=1.25,height=3.75,color="#888888",fill_color="#333333",fill_opacity=1).move_to([-0.625,-1.125,0])
polyf= Rectangle(width=1,height=2,color="#888888").move_to([-2.5,-2,0])
self.play(ShowCreation(polyb),ShowCreation(polye),run_time=2)
self.wait()
self.play(ShowCreation(polyc),ShowCreation(polyf),run_time=2)
self.wait()
self.play(ShowCreation(polya.move_to(polyd)),ShowCreation(polyd),run_time=2)
self.wait()
self.add(TextMobject("B").move_to(polyb))
self.add(TextMobject("C").move_to(polyc))
self.add(TextMobject("E").move_to(polye))
self.add(linex)
self.add(Rectangle(width=14.22,height=8))
text=TexMobject(r"polya.scale(0.5)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.scale(0.5),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.scale\_in\_place(2)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.scale_in_place(2),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.scale\_about\_point(0.5,[-1,-1,0])").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.scale_about_point(0.5,[-1,-1,0]),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch(1.5,[1,1,0])").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch(1.5,[1,1,0]),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch\_about\_point(1.5,[1,1,0],[1,1.5,0])").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch_about_point(1.5,[1,1,0],[1,1.5,0]),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch\_in\_place(0.5,[1,1,0])").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch_in_place(0.5,[1,1,0]),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.rescale\_to\_fit(1.25,[1,1,0])").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.rescale_to_fit(1.25,[1,1,0]),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch\_to\_fit\_width(1.25)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch_to_fit_width(1.25),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch\_to\_fit\_height(4)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch_to_fit_height(4),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.stretch\_to\_fit\_depth(1)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.stretch_to_fit_depth(1),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.set\_width(0.75)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.set_width(0.75),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.set\_height(1.25)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.set_height(1.25),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
text=TexMobject(r"polya.set\_depth(1)").move_to([0,3,0])
self.play(Write(text),ApplyFunction(lambda mob:mob.set_depth(1),polya),run_time=3)
self.wait()
self.play(FadeOut(text),run_time=2)
Output
©sideway
ID: 200301302 Last Updated: 3/13/2020 Revision: 0
|
 |