Skip to main content

Create VideoScribe-like hand-drawn animation timelines and SVG frames in Python

Project description

handrawpy

handrawpy 是一个轻量 Python 包,用来生成类似 VideoScribe 的手绘白板动画。

功能

  • 以路径(折线)为单位描述绘制步骤
  • 自动生成逐帧时间线(包含“人手+笔”同步移动效果)
  • 导出逐帧 SVG(便于后处理或转视频)
  • 可选使用 Pillow 直接导出 GIF
  • 内置 show_ui() 桌面预览窗口(播放/调速/导出 SVG 与 GIF)

安装

pip install -e .
# 若需要 GIF 输出
pip install -e .[render]

快速开始

from handrawpy import Scene, Animator

scene = Scene(width=800, height=450, background="#ffffff")
scene.add_stroke([(100, 300), (180, 120), (260, 300)], duration=1.0, color="#111", width=4)
scene.add_stroke([(320, 300), (420, 120), (520, 300)], duration=1.2, delay=0.2, color="#111", width=4)

animator = Animator(scene, fps=24)

# 导出 SVG 序列
animator.save_svg_sequence("out_frames")

# 可选:导出 GIF(需要 Pillow)
# animator.render_gif("demo.gif")

预览窗口(show_ui)

如果你希望“生成后立刻在本地窗口播放动画,并在界面里点按钮导出文件”,可以直接调用:

from handrawpy import Scene, Animator

scene = Scene(width=900, height=300, background="#ffffff")
scene.add_stroke([(50, 160), (220, 160)], duration=0.6, width=5)
scene.add_stroke([(260, 160), (420, 80), (580, 160)], duration=0.9, width=5)

animator = Animator(scene, fps=24)
animator.show_ui()

窗口支持:

  • 播放 / 暂停
  • 速度调节(0.25x - 3x)
  • 导出 SVG 序列
  • 导出 GIF(需要 pip install -e .[render]

设计说明

  • Scene:画布 + 绘制步骤容器
  • DrawStep:一条路径在给定时长内完成绘制
  • Animator:把步骤转换为逐帧状态,可输出 SVG/GIF

这个库目前聚焦“路径描边型”白板动画,并内置简化的手部笔刷跟随。后续可扩展:

  • 文字/图片自动描边
  • 更真实的手部 PNG sprite
  • 镜头运动与缩放
  • MP4 直接导出(ffmpeg)

示例:从左到右写出 “I Love You”

项目已提供可直接运行的示例脚本:examples/i_love_you.py

python examples/i_love_you.py

该脚本已内置源码目录导入逻辑,无需先 pip install 也可直接运行。

脚本会:

  • from handrawpy import Scene, Animator 导入包
  • 以字母笔画(折线)定义 I LOVE YOU
  • 按从左到右顺序将笔画加入时间线
  • 导出 SVG 帧序列到 out_i_love_you_svg/
  • 可选调用 show_ui() 在桌面窗口直接预览并手动导出

如需 GIF,可安装可选依赖后取消脚本中的 render_gif 注释:

pip install -e .[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

handrawpy-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

handrawpy-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file handrawpy-0.1.0.tar.gz.

File metadata

  • Download URL: handrawpy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for handrawpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d48a28daf8f723f8d0898365e733f6e14d54bb6bb11bb5fd8962fe2024afdf6
MD5 71fee2b42af5af8fa13a87a4a2127998
BLAKE2b-256 86a502df5e6f605f4b4d3f0df52929fb3ea52bcdd8a7a255afda748b5bb60dc5

See more details on using hashes here.

File details

Details for the file handrawpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: handrawpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for handrawpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da017d96a5ccb755054c1e41b40d99cc993927b5ad126b6bfb57c0ce27be10d7
MD5 18231fe6bf0fd5a83935f6cd7f55d19e
BLAKE2b-256 62a9ab16b93b981d9f9b6d77245cd354274c3919576cd5ac50b1f8f42c3a725e

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