Skip to main content

A Python library for rendering code videos

Project description

发现任何问题请发送至我的邮箱,欢迎大家来找茬,我们会尽快修复。

CodeVideoRenderer 1.0.3

修复

  • 代码偏移(manim自带bug)

  • 换行时相机不及时移动

  • 光标在换行时不在开头停顿

更新

  • 每行代码首尾空白字符不参与动画,以免增加动画时长

  • 当前行背景宽度更改

  • 新增line_spacing参数用于更改行距

优化

  • 终端渲染信息

  • 相机移动

旧版本支持功能

  • 光标打字

  • 相机持续移动

  • 参数及代码检测


本库用于生成输入代码的视频,视频视角会跟随光标移动。(视频生成时间可能略长,请耐心等待)

提示:使用manim进行动画渲染,使用前请确保manim能够正常运行。

本库提供CodeVideo,您可以用它来创建一个视频对象。参数如下:

(function) def CodeVideo(
    video_name: str = "CodeVideo",
    code_string: str = None,
    code_file: str = None,
    font: str = 'Consolas',
    language: str = None,
    line_spacing: float = 0.7,
    interval_range: tuple[float, float] = (0.2, 0.2),
    camera_floating_maximum_value: float = 0.1,
    camera_move_interval: float = 0.1,
    camera_move_duration: float = 0.5,
    screen_scale: float = 0.5
) -> code_video

参数说明

  • video_name:生成视频的文件名,默认值为"CodeVideo"

  • code_string:直接传入的代码字符串

  • code_file:代码文件路径

  • font:代码显示字体,默认值为'Consolas'

  • language:代码语言(用于语法高亮)

  • line_spacing:代码行间距,默认值为0.7

  • interval_range:字符显示的时间间隔范围(秒),元组形式,默认(0.2, 0.2),最小值为0.2

  • camera_floating_maximum_value:相机浮动的最大范围,默认0.1,值≥0

  • camera_move_interval:相机自动移动的时间间隔(秒),默认0.1,值≥0

  • camera_move_duration:相机移动的持续时间(秒),默认0.5,值≥0

  • screen_scale:屏幕缩放比例,默认值为0.5

注:所有带范围限制的参数均不能小于指定最小值,code_stringcode_file不能同时传入。


本库使用pydantic中的validate_call,在你传入参数时会自动检查参数类型,以确保其正确性。

你可以使用CodeVideo对象的render方法来生成视频,你可以在终端中查看视频的保存位置。

示例

from CodeVideoRenderer import *
video = CodeVideo(code_string="print('Hello World!')", language='python')
video.render()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codevideorenderer-1.0.3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codevideorenderer-1.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file codevideorenderer-1.0.3.tar.gz.

File metadata

  • Download URL: codevideorenderer-1.0.3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for codevideorenderer-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ecd6d1b82d5d5b8812dad73ceed8544b8b7d860a2c22c436cebc1c6d344368cb
MD5 8a97a2ca4364e188057388842e169b7b
BLAKE2b-256 285badb2cb3ee80ccf3666fa584b63601a2c49d6446ebeb27807d19f36f4531b

See more details on using hashes here.

File details

Details for the file codevideorenderer-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for codevideorenderer-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 289b0104fce692b48f2451837ffcebf704f96f7c1d48c7e5a4706473c9e4ebf9
MD5 28727817f0f11f506ddb10feb7db9917
BLAKE2b-256 40e02dbcf490ff57cbff59a11d87c3cd189b421242ef7dce6a0f49267babb15f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page