Metadata-Version: 2.4
Name: handrawpy
Version: 0.1.0
Summary: Create VideoScribe-like hand-drawn animation timelines and SVG frames in Python
Author: handrawPy contributors
License: MIT
Keywords: animation,svg,whiteboard,handdrawn,videoscribe
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: render
Requires-Dist: Pillow>=10.0; extra == "render"
Dynamic: license-file

# handrawpy

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

## 功能

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

## 安装

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

## 快速开始

```python
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）

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

```python
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`。

```bash
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` 注释：

```bash
pip install -e .[render]
```
