mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Fix the idle_stream()'s sleep duration and change the stream FPS to 30
This commit is contained in:
parent
846a824947
commit
db7f8320bd
4 changed files with 13 additions and 22 deletions
|
@ -15,8 +15,6 @@ from utils.paths import counterclockwise_path
|
||||||
from utils.rate_functions import double_smooth
|
from utils.rate_functions import double_smooth
|
||||||
from utils.rate_functions import smooth
|
from utils.rate_functions import smooth
|
||||||
|
|
||||||
import position
|
|
||||||
|
|
||||||
# Drawing
|
# Drawing
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,14 +99,6 @@ class Write(DrawBorderThenFill):
|
||||||
else:
|
else:
|
||||||
mobject = mob_or_text
|
mobject = mob_or_text
|
||||||
|
|
||||||
if IS_LIVE_STREAMING:
|
|
||||||
print(position.current)
|
|
||||||
mobject.shift(position.current)
|
|
||||||
position.current = position.current + 2 * DOWN
|
|
||||||
if position.current[1] < -3:
|
|
||||||
position.current[1] = 3
|
|
||||||
position.current = position.current + 3 * RIGHT
|
|
||||||
|
|
||||||
if "run_time" not in kwargs:
|
if "run_time" not in kwargs:
|
||||||
self.establish_run_time(mobject)
|
self.establish_run_time(mobject)
|
||||||
if "lag_factor" not in kwargs:
|
if "lag_factor" not in kwargs:
|
||||||
|
|
2
manim.py
2
manim.py
|
@ -26,6 +26,6 @@ class Manim():
|
||||||
"end_at_animation_number": None,
|
"end_at_animation_number": None,
|
||||||
"skip_animations": False,
|
"skip_animations": False,
|
||||||
"camera_config": HIGH_QUALITY_CAMERA_CONFIG,
|
"camera_config": HIGH_QUALITY_CAMERA_CONFIG,
|
||||||
"frame_duration": PRODUCTION_QUALITY_FRAME_DURATION,
|
"frame_duration": MEDIUM_QUALITY_FRAME_DURATION,
|
||||||
}
|
}
|
||||||
return Scene(**kwargs)
|
return Scene(**kwargs)
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from constants import *
|
|
||||||
|
|
||||||
current = 5 * LEFT + 3 * UP
|
|
|
@ -18,7 +18,7 @@ from tqdm import tqdm as ProgressDisplay
|
||||||
from constants import *
|
from constants import *
|
||||||
|
|
||||||
from animation.animation import Animation
|
from animation.animation import Animation
|
||||||
from animation.transform import MoveToTarget
|
from animation.transform import MoveToTarget, ApplyMethod
|
||||||
from camera.camera import Camera
|
from camera.camera import Camera
|
||||||
from continual_animation.continual_animation import ContinualAnimation
|
from continual_animation.continual_animation import ContinualAnimation
|
||||||
from mobject.mobject import Mobject
|
from mobject.mobject import Mobject
|
||||||
|
@ -29,9 +29,9 @@ from utils.output_directory_getters import get_image_output_directory
|
||||||
|
|
||||||
from container.container import Container
|
from container.container import Container
|
||||||
|
|
||||||
import position
|
|
||||||
from mobject.svg.tex_mobject import TextMobject
|
from mobject.svg.tex_mobject import TextMobject
|
||||||
from animation.creation import Write
|
from animation.creation import Write
|
||||||
|
import datetime
|
||||||
|
|
||||||
class Scene(Container):
|
class Scene(Container):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
@ -346,10 +346,6 @@ class Scene(Container):
|
||||||
self.mobjects = []
|
self.mobjects = []
|
||||||
self.foreground_mobjects = []
|
self.foreground_mobjects = []
|
||||||
self.continual_animation = []
|
self.continual_animation = []
|
||||||
|
|
||||||
if IS_LIVE_STREAMING:
|
|
||||||
position.current = 5 * LEFT + 3 * UP
|
|
||||||
print(position.current)
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def get_mobjects(self):
|
def get_mobjects(self):
|
||||||
|
@ -515,11 +511,15 @@ class Scene(Container):
|
||||||
|
|
||||||
def idle_stream(self):
|
def idle_stream(self):
|
||||||
while(self.stream_lock):
|
while(self.stream_lock):
|
||||||
|
a = datetime.datetime.now()
|
||||||
self.update_frame()
|
self.update_frame()
|
||||||
n_frames = 1
|
n_frames = 1
|
||||||
frame = self.get_frame()
|
frame = self.get_frame()
|
||||||
self.add_frames(*[frame] * n_frames)
|
self.add_frames(*[frame] * n_frames)
|
||||||
sleep(self.frame_duration * 99/100)
|
b = datetime.datetime.now()
|
||||||
|
time_diff = (b - a).total_seconds()
|
||||||
|
if time_diff < self.frame_duration:
|
||||||
|
sleep(self.frame_duration - time_diff)
|
||||||
|
|
||||||
def clean_up_animations(self, *animations):
|
def clean_up_animations(self, *animations):
|
||||||
for animation in animations:
|
for animation in animations:
|
||||||
|
@ -677,7 +677,11 @@ class Scene(Container):
|
||||||
|
|
||||||
def tex(self, latex):
|
def tex(self, latex):
|
||||||
eq = TextMobject(latex)
|
eq = TextMobject(latex)
|
||||||
self.play(Write(eq))
|
anims = []
|
||||||
|
anims.append(Write(eq))
|
||||||
|
for mobject in self.mobjects:
|
||||||
|
anims.append(ApplyMethod(mobject.shift,2*UP))
|
||||||
|
self.play(*anims)
|
||||||
|
|
||||||
|
|
||||||
class EndSceneEarlyException(Exception):
|
class EndSceneEarlyException(Exception):
|
||||||
|
|
Loading…
Add table
Reference in a new issue