mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Fixed ContinualUpdateFromFunc issue
This commit is contained in:
parent
22d6d2dba5
commit
4919dbf652
1 changed files with 12 additions and 5 deletions
|
@ -94,16 +94,23 @@ class AmbientMovement(ContinualAnimation):
|
|||
self.mobject.shift(dt*self.rate*self.direction)
|
||||
|
||||
class ContinualUpdateFromFunc(ContinualAnimation):
|
||||
CONFIG = {
|
||||
"function_depends_on_dt" : False
|
||||
}
|
||||
def __init__(self, mobject, func, **kwargs):
|
||||
self.func = func
|
||||
self.func_arg_count = func.func_code.co_argcount
|
||||
if self.func_arg_count > 2:
|
||||
raise Exception("ContinualUpdateFromFunc function must take 1 or 2 args")
|
||||
ContinualAnimation.__init__(self, mobject, **kwargs)
|
||||
|
||||
def update_mobject(self, dt):
|
||||
args = (self.mobject, dt)
|
||||
self.func(*args[:self.func_arg_count])
|
||||
if self.function_depends_on_dt:
|
||||
self.func(self.mobject, dt)
|
||||
else:
|
||||
self.func(self.mobject)
|
||||
|
||||
class ContinualUpdateFromTimeFunc(ContinualUpdateFromFunc):
|
||||
CONFIG = {
|
||||
"function_depends_on_dt" : True
|
||||
}
|
||||
|
||||
class ContinualMaintainPositionRelativeTo(ContinualAnimation):
|
||||
# TODO: Possibly reimplement using CycleAnimation?
|
||||
|
|
Loading…
Add table
Reference in a new issue