processing / processing/libprocessing

Livecoding Mode for Python

未關閉
#61 4 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

@catilac 已經在處理了。

開始於 2026年1月24日。

主要語言
Rust
星號
69
分支
14
平均合併
15 天 22 小時
30 天內合併 PR
3

描述

Leverage bevy_ecs to watch the currently running sketch for changes and hotswap on successfully compiling edits

Edit: I'm currently working on this, but there are some architectural questions I have.

Current Approach

I've created a new bevy Asset called Sketch and spawn that object at Startup.
When I make a change to sketch.py bevy will notice. yay

The question now is how does the actual reloading mechanism work for Python? And there is a larger question of how does this mechanism work for other language frontends (Processing4/java, lua, ocaml, scheme, ruby, etc...)

For Python (w/ pyo3)

  1. Make a change to sketch.py
  2. Bevy will observe and [emit an event]
  3. processing_pyo3 crate will check if a reload is necessary
  4. Using something like importlib.reload(), pyo3 can reload the module, and skip creating a new graphics context if it doesn't have to, and grab the new draw and setup functions.
+--------+        +------+
| Python |------->| Bevy |
+--------+        +------+
   ^                |
   |                |
   +-- onChange ----+

What about other language front-ends?

I suppose some custom plugin loading could work. The Sketch Asset could be something that Python introduces, so that would allow for us to only use any of that design only for our pyo3 implementation

The other front-ends would have to build their own systems, and we could expose hot-reloading related FFI methods?

I think at the moment, I really like the idea of just having a Python related Livecoding bevy plugin. I'm still learning about bevy's ECS system, but is it possible for us to represent our "scene graph" as an intermediary that can easily map to the existing entities in bevy?

ie:

def draw():
    background(220)

    fill(255, 0, 100)
    stroke(0)
    stroke_weight(2)
    rect(100, 100, 200, 150)

when I change stroke_weight, could bevy know to update, or refresh that particular entity?
or is it easier to just drop all the entities and re-run the sketch? I might be over thinking it.

For now I'm going to work towards getting python to hotreload.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。