代码视频渲染器(CodeVideoRenderer)
示例
安装
pip install CodeVideoRenderer 方法一
from CodeVideoRenderer import CodeVideo
CodeVideo(
video_name="demo",
code_string='print("Hello World")',
language="python"
).render()方法二
from CodeVideoRenderer import CodeVideo
code_to_render = '''from manim import *
class PiCalculation(Scene):
def construct(self):
# create circle and diameter
radius = 2
circle = Circle(radius=radius, color=BLUE)
diameter_line = Line(circle.get_left(), circle.get_right(), color=YELLOW)
# label radius and diameter
radius_text = MathTex("r").next_to(circle.get_top(), UP)
diameter_text = MathTex("d").next_to(diameter_line.get_top(), UP)
self.play(Create(circle))
self.play(Create(diameter_line))
self.play(Write(radius_text), Write(diameter_text))
self.wait(1)
# show formula: pi = C / d
formula = MathTex(r"\\pi = \\frac{C}{d}").to_edge(UP)
self.play(Write(formula))
self.wait(1)
# red dot moves along circle to illustrate circumference
dot = Dot(circle.get_right(), color=RED)
self.add(dot)
self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)
# show final formula
circumference_text = MathTex(r"C \\approx 2 \\pi r").next_to(circle, DOWN)
self.play(Write(circumference_text))
self.wait(2)
'''
video = CodeVideo(
video_name="pi_calculation_code",
code_string=code_to_render,
language="python",
line_spacing=0.8
)
video.render()注意事项
使用manim进行动画渲染,使用前请确保manim能够正常运行
短代码演示请使用方法一,长代码演示使用方法二
Hi, everything is going nicely here and ofcourse every one is sharing information, that's really fine, keep
up writing.
https://gravatar.com/mysticalexactlyb0d29d5527
https://cs.gravatar.com/nisgolategesmei
https://gravatar.com/happilytenacious4128be0b6c
https://gravatar.com/quickly2bb857c4ad
https://gravatar.com/friedcreativelyc365a09dac
https://gravatar.com/thoughtfullyllamab198e0fad6
https://gravatar.com/innermortallyd7388d45ee
https://gravatar.com/baby22a688eef2e
https://gravatar.com/sensationallyfading4678bd29cf
https://gravatar.com/almostbeautiful15f530752f