Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 169 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type_complexity = "allow"
too_many_arguments = "allow"

[workspace.dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main" }
bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", features = ["file_watcher"] }
processing = { path = "." }
processing_pyo3 = { path = "crates/processing_pyo3" }
processing_render = { path = "crates/processing_render" }
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def draw():
background(220)

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

Expand Down
26 changes: 25 additions & 1 deletion crates/processing_pyo3/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ impl Topology {
}
}

#[pyclass]
pub struct Sketch {
pub source: String,
}

#[pymethods]
impl Geometry {
#[new]
Expand Down Expand Up @@ -115,12 +120,20 @@ impl Drop for Graphics {
#[pymethods]
impl Graphics {
#[new]
pub fn new(width: u32, height: u32, asset_path: &str) -> PyResult<Self> {
pub fn new(
width: u32,
height: u32,
asset_path: &str,
sketch_root_path: &str,
sketch_file_name: &str,
) -> PyResult<Self> {
let glfw_ctx =
GlfwContext::new(width, height).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;

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

let surface = glfw_ctx
Expand All @@ -141,6 +154,17 @@ impl Graphics {
})
}

pub fn poll_for_sketch_update(&self) -> PyResult<Sketch> {
match poll_for_sketch_updates().map_err(|_| PyRuntimeError::new_err("SKETCH UPDATE ERR"))? {
Some(sketch) => Ok(Sketch {
source: sketch.source,
}),
None => Ok(Sketch {
source: "".to_string(),
}),
}
}

pub fn background(&self, args: Vec<f32>) -> PyResult<()> {
let (r, g, b, a) = parse_color(&args)?;
let color = bevy::color::Color::srgba(r, g, b, a);
Expand Down
Loading
Loading