mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Minor improvements to vibrating string, plus copy method to animation
This commit is contained in:
parent
6a10e775b9
commit
723103fb9a
2 changed files with 11 additions and 7 deletions
|
@ -6,6 +6,7 @@ import time
|
||||||
import os
|
import os
|
||||||
import progressbar
|
import progressbar
|
||||||
import inspect
|
import inspect
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from mobject import Mobject
|
from mobject import Mobject
|
||||||
|
@ -30,6 +31,9 @@ class Animation(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
return deepcopy(self)
|
||||||
|
|
||||||
def update(self, alpha):
|
def update(self, alpha):
|
||||||
if alpha < 0:
|
if alpha < 0:
|
||||||
alpha = 0.0
|
alpha = 0.0
|
||||||
|
|
|
@ -9,13 +9,13 @@ from helpers import *
|
||||||
class VibratingString(Animation):
|
class VibratingString(Animation):
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"num_periods" : 1,
|
"num_periods" : 1,
|
||||||
"overtones" : 4,
|
"overtones" : 4,
|
||||||
"amplitude" : 0.5,
|
"amplitude" : 0.5,
|
||||||
"radius" : SPACE_WIDTH/2,
|
"radius" : SPACE_WIDTH/2,
|
||||||
"center" : ORIGIN,
|
"center" : ORIGIN,
|
||||||
"color" : "white",
|
"color" : "white",
|
||||||
"run_time" : 3.0,
|
"run_time" : 3.0,
|
||||||
"alpha_func" : None
|
"alpha_func" : None
|
||||||
}
|
}
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue