mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Add automatic positioning for live streams
This commit is contained in:
parent
815b3103c4
commit
846a824947
3 changed files with 27 additions and 1 deletions
|
@ -15,6 +15,8 @@ from utils.paths import counterclockwise_path
|
|||
from utils.rate_functions import double_smooth
|
||||
from utils.rate_functions import smooth
|
||||
|
||||
import position
|
||||
|
||||
# Drawing
|
||||
|
||||
|
||||
|
@ -98,6 +100,15 @@ class Write(DrawBorderThenFill):
|
|||
mobject = TextMobject(mob_or_text)
|
||||
else:
|
||||
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:
|
||||
self.establish_run_time(mobject)
|
||||
if "lag_factor" not in kwargs:
|
||||
|
|
3
position.py
Normal file
3
position.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from constants import *
|
||||
|
||||
current = 5 * LEFT + 3 * UP
|
|
@ -29,6 +29,9 @@ from utils.output_directory_getters import get_image_output_directory
|
|||
|
||||
from container.container import Container
|
||||
|
||||
import position
|
||||
from mobject.svg.tex_mobject import TextMobject
|
||||
from animation.creation import Write
|
||||
|
||||
class Scene(Container):
|
||||
CONFIG = {
|
||||
|
@ -343,6 +346,10 @@ class Scene(Container):
|
|||
self.mobjects = []
|
||||
self.foreground_mobjects = []
|
||||
self.continual_animation = []
|
||||
|
||||
if IS_LIVE_STREAMING:
|
||||
position.current = 5 * LEFT + 3 * UP
|
||||
print(position.current)
|
||||
return self
|
||||
|
||||
def get_mobjects(self):
|
||||
|
@ -512,7 +519,7 @@ class Scene(Container):
|
|||
n_frames = 1
|
||||
frame = self.get_frame()
|
||||
self.add_frames(*[frame] * n_frames)
|
||||
sleep(self.frame_duration * 999/1000)
|
||||
sleep(self.frame_duration * 99/100)
|
||||
|
||||
def clean_up_animations(self, *animations):
|
||||
for animation in animations:
|
||||
|
@ -631,6 +638,7 @@ class Scene(Container):
|
|||
'-pix_fmt', 'rgba',
|
||||
'-r', str(fps), # frames per second
|
||||
'-i', '-', # The imput comes from a pipe
|
||||
'-c:v', 'h264_nvenc',
|
||||
'-an', # Tells FFMPEG not to expect any audio
|
||||
'-loglevel', 'error',
|
||||
]
|
||||
|
@ -667,6 +675,10 @@ class Scene(Container):
|
|||
else:
|
||||
os.rename(*self.args_to_rename_file)
|
||||
|
||||
def tex(self, latex):
|
||||
eq = TextMobject(latex)
|
||||
self.play(Write(eq))
|
||||
|
||||
|
||||
class EndSceneEarlyException(Exception):
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue