Skip to content

Commit 02e6ec6

Browse files
authored
Merge branch 'main' into pyo3/lights
2 parents f632122 + 2098b83 commit 02e6ec6

File tree

8 files changed

+390
-14
lines changed

8 files changed

+390
-14
lines changed

Cargo.lock

Lines changed: 169 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type_complexity = "allow"
2121
too_many_arguments = "allow"
2222

2323
[workspace.dependencies]
24-
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main" }
24+
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", features = ["file_watcher"] }
2525
processing = { path = "." }
2626
processing_pyo3 = { path = "crates/processing_pyo3" }
2727
processing_render = { path = "crates/processing_render" }

crates/processing_pyo3/examples/rectangle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def draw():
77
background(220)
88

99
fill(255, 0, 100)
10-
stroke(0)
10+
stroke(1)
1111
stroke_weight(2)
1212
rect(100, 100, 200, 150)
1313

crates/processing_pyo3/src/graphics.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ impl Topology {
8686
}
8787
}
8888

89+
#[pyclass]
90+
pub struct Sketch {
91+
pub source: String,
92+
}
93+
8994
#[pymethods]
9095
impl Geometry {
9196
#[new]
@@ -140,12 +145,20 @@ impl Drop for Graphics {
140145
#[pymethods]
141146
impl Graphics {
142147
#[new]
143-
pub fn new(width: u32, height: u32, asset_path: &str) -> PyResult<Self> {
148+
pub fn new(
149+
width: u32,
150+
height: u32,
151+
asset_path: &str,
152+
sketch_root_path: &str,
153+
sketch_file_name: &str,
154+
) -> PyResult<Self> {
144155
let glfw_ctx =
145156
GlfwContext::new(width, height).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
146157

147158
let mut config = Config::new();
148159
config.set(ConfigKey::AssetRootPath, asset_path.to_string());
160+
config.set(ConfigKey::SketchRootPath, sketch_root_path.to_string());
161+
config.set(ConfigKey::SketchFileName, sketch_file_name.to_string());
149162
init(config).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
150163

151164
let surface = glfw_ctx
@@ -166,6 +179,17 @@ impl Graphics {
166179
})
167180
}
168181

182+
pub fn poll_for_sketch_update(&self) -> PyResult<Sketch> {
183+
match poll_for_sketch_updates().map_err(|_| PyRuntimeError::new_err("SKETCH UPDATE ERR"))? {
184+
Some(sketch) => Ok(Sketch {
185+
source: sketch.source,
186+
}),
187+
None => Ok(Sketch {
188+
source: "".to_string(),
189+
}),
190+
}
191+
}
192+
169193
pub fn background(&self, args: Vec<f32>) -> PyResult<()> {
170194
let (r, g, b, a) = parse_color(&args)?;
171195
let color = bevy::color::Color::srgba(r, g, b, a);

0 commit comments

Comments
 (0)