There is a square location in the ORIGIN, I want to move it to UP*3 and scale to 0.5 at the same with below code snippet:
sq = Square()
self.add(sq)
self.play(ApplyMethod(sq.scale, 0.5), ApplyMethod(sq.move_to, UP*3), run_time=5)
However, the first one is skipped, only the last one works.
I know creating another small square and using transform can do, but that will bring more code, is there simple solution for this? thanks!
There are 3 ways:
class MultipleMethods1(Scene):
def construct(self):
sq = Square()
self.add(sq)
self.play(
sq.scale, 0.5,
sq.move_to, UP*3,
run_time=5
)
self.wait()
class MultipleMethods2(Scene):
def construct(self):
sq = Square()
cr = Circle()
VGroup(sq,cr).arrange(RIGHT)
self.add(sq)
def apply_function(mob):
mob.scale(0.5)
mob.shift(UP*3)
return mob
self.play(
ApplyFunction(apply_function,sq),
ApplyFunction(apply_function,cr),
run_time=5
)
self.wait()
class MultipleMethods3(Scene):
def construct(self):
sq = Square()
self.add(sq)
sq.generate_target()
sq.target.scale(0.5)
sq.target.move_to(UP*3)
self.play(
MoveToTarget(sq),
run_time=5
)
self.wait()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With