From 8e1ef74d22d42453425d19449b85962b8c05db5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sun, 28 Dec 2025 18:30:30 -0800 Subject: [PATCH 1/8] box.py sketch --- crates/processing_pyo3/examples/box.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 crates/processing_pyo3/examples/box.py diff --git a/crates/processing_pyo3/examples/box.py b/crates/processing_pyo3/examples/box.py new file mode 100644 index 0000000..e665ee7 --- /dev/null +++ b/crates/processing_pyo3/examples/box.py @@ -0,0 +1,25 @@ +from processing import * + +angle = 0.0 + +def setup(): + size(800, 600, 1.0) + mode_3d() + +def draw(): + camera_position(100.0, 100.0, 300.0) + camera_look_at(0.0, 0.0, 0.0) + background(220) + + + push_matrix() + rotate(angle) + geometry(box) + pop_matrix() + + angle += 0.02 + + +# TODO: this should happen implicitly on module load somehow +run() + From f07f458944bccf73f9e01b60f0cae299b0c2d7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sun, 28 Dec 2025 20:43:11 -0800 Subject: [PATCH 2/8] box example working --- crates/processing_pyo3/examples/box.py | 5 ++- crates/processing_pyo3/src/graphics.rs | 6 +++ crates/processing_pyo3/src/lib.rs | 54 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/crates/processing_pyo3/examples/box.py b/crates/processing_pyo3/examples/box.py index e665ee7..28562be 100644 --- a/crates/processing_pyo3/examples/box.py +++ b/crates/processing_pyo3/examples/box.py @@ -3,10 +3,11 @@ angle = 0.0 def setup(): - size(800, 600, 1.0) + size(800, 600) mode_3d() def draw(): + global angle camera_position(100.0, 100.0, 300.0) camera_look_at(0.0, 0.0, 0.0) background(220) @@ -14,7 +15,7 @@ def draw(): push_matrix() rotate(angle) - geometry(box) + draw_box(100.0, 100.0, 100.0) pop_matrix() angle += 0.02 diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 00245f8..273e83f 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -173,6 +173,12 @@ impl Graphics { .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) } + pub fn draw_box(&self, x: f32, y: f32, z: f32) -> PyResult<()> { + let box_geo = geometry_box(x, y, z).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; + graphics_record_command(self.entity, DrawCommand::Geometry(box_geo)) + .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } + pub fn scale(&self, x: f32, y: f32) -> PyResult<()> { graphics_record_command(self.entity, DrawCommand::Scale { x, y }) .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 3e5d07a..02ea67f 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -22,6 +22,13 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_function(wrap_pyfunction!(size, m)?)?; m.add_function(wrap_pyfunction!(run, m)?)?; + m.add_function(wrap_pyfunction!(mode_3d, m)?)?; + m.add_function(wrap_pyfunction!(camera_position, m)?)?; + m.add_function(wrap_pyfunction!(camera_look_at, m)?)?; + m.add_function(wrap_pyfunction!(push_matrix, m)?)?; + m.add_function(wrap_pyfunction!(pop_matrix, m)?)?; + m.add_function(wrap_pyfunction!(rotate, m)?)?; + m.add_function(wrap_pyfunction!(draw_box, m)?)?; m.add_function(wrap_pyfunction!(background, m)?)?; m.add_function(wrap_pyfunction!(fill, m)?)?; m.add_function(wrap_pyfunction!(no_fill, m)?)?; @@ -97,6 +104,53 @@ fn run(module: &Bound<'_, PyModule>) -> PyResult<()> { }) } +#[pyfunction] +#[pyo3(pass_module)] +fn mode_3d(module: &Bound<'_, PyModule>) -> PyResult<()> { + get_graphics(module)?.mode_3d() +} + +#[pyfunction] +#[pyo3(pass_module)] +fn camera_position(module: &Bound<'_, PyModule>, x: f32, y: f32, z: f32) -> PyResult<()> { + get_graphics(module)?.camera_position(x, y, z) +} + +#[pyfunction] +#[pyo3(pass_module)] +fn camera_look_at( + module: &Bound<'_, PyModule>, + target_x: f32, + target_y: f32, + target_z: f32, +) -> PyResult<()> { + get_graphics(module)?.camera_look_at(target_x, target_y, target_z) +} + +#[pyfunction] +#[pyo3(pass_module)] +fn push_matrix(module: &Bound<'_, PyModule>) -> PyResult<()> { + get_graphics(module)?.push_matrix() +} + +#[pyfunction] +#[pyo3(pass_module)] +fn pop_matrix(module: &Bound<'_, PyModule>) -> PyResult<()> { + get_graphics(module)?.push_matrix() +} + +#[pyfunction] +#[pyo3(pass_module)] +fn rotate(module: &Bound<'_, PyModule>, angle: f32) -> PyResult<()> { + get_graphics(module)?.rotate(angle) +} + +#[pyfunction] +#[pyo3(pass_module)] +fn draw_box(module: &Bound<'_, PyModule>, x: f32, y: f32, z: f32) -> PyResult<()> { + get_graphics(module)?.draw_box(x, y, z) +} + #[pyfunction] #[pyo3(pass_module, signature = (*args))] fn background(module: &Bound<'_, PyModule>, args: &Bound<'_, PyTuple>) -> PyResult<()> { From 2241e99a5374b53d645bc95073a4b44ef6ee1d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Wed, 31 Dec 2025 10:11:31 -0800 Subject: [PATCH 3/8] wip animated_mesh.py --- .../processing_pyo3/examples/animated_mesh.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 crates/processing_pyo3/examples/animated_mesh.py diff --git a/crates/processing_pyo3/examples/animated_mesh.py b/crates/processing_pyo3/examples/animated_mesh.py new file mode 100644 index 0000000..da51aaa --- /dev/null +++ b/crates/processing_pyo3/examples/animated_mesh.py @@ -0,0 +1,42 @@ +from processing import * + +mesh = None +grid_size = 20 +spacing = 10.0 + +def setup(): + size(800, 600) + mode_3d() + global mesh = geometry_create(TriangleList) + +def draw(): + # TODO: maybe all of this should be in `setup()` + global grid_size + + for z in range(grid_size): + for x in range(grid_size): + px = x * spacing - offset + pz = z * spacing - offset + geometry_color(mesh, x/grid_size, 0.5, z/grid_size, 1.0) + geometry_normal(mesh, 0.0,1.0,0.0) + geometry_vertex(mesh, px, 0.0, pz) + for z in range(grid_size-1): + for x in range(grid_size-1): + tl = z * grid_size + x + tr = tl + 1 + bl = (z + 1) * grid_size + x + br = bl + 1 + + geometry_index(mesh, tl) + geometry_index(mesh, bl) + geometry_index(mesh, tr) + + geometry_index(mesh, tr) + geometry_index(mesh, bl) + geometry_index(mesh, br) + + + + +# TODO: this should happen implicitly on module load somehow +run() From 3d70536885b9278e6926914253f1d507d6f453a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Thu, 8 Jan 2026 21:11:59 -0500 Subject: [PATCH 4/8] rendering mesh --- .../processing_pyo3/examples/animated_mesh.py | 42 ++++++++++++------- crates/processing_pyo3/examples/box.py | 1 - crates/processing_pyo3/src/graphics.rs | 37 ++++++++++++++++ crates/processing_pyo3/src/lib.rs | 11 ++++- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/crates/processing_pyo3/examples/animated_mesh.py b/crates/processing_pyo3/examples/animated_mesh.py index da51aaa..c811a93 100644 --- a/crates/processing_pyo3/examples/animated_mesh.py +++ b/crates/processing_pyo3/examples/animated_mesh.py @@ -3,23 +3,21 @@ mesh = None grid_size = 20 spacing = 10.0 +offset = (grid_size * spacing) / 2.0; def setup(): + global mesh size(800, 600) mode_3d() - global mesh = geometry_create(TriangleList) - -def draw(): - # TODO: maybe all of this should be in `setup()` - global grid_size - + mesh = Mesh() for z in range(grid_size): for x in range(grid_size): px = x * spacing - offset pz = z * spacing - offset - geometry_color(mesh, x/grid_size, 0.5, z/grid_size, 1.0) - geometry_normal(mesh, 0.0,1.0,0.0) - geometry_vertex(mesh, px, 0.0, pz) + mesh.color(x/grid_size, 0.5, z/grid_size, 1.0) + mesh.normal(0.0, 1.0, 0.0) + mesh.vertex(px, 0.0, pz) + for z in range(grid_size-1): for x in range(grid_size-1): tl = z * grid_size + x @@ -27,15 +25,27 @@ def draw(): bl = (z + 1) * grid_size + x br = bl + 1 - geometry_index(mesh, tl) - geometry_index(mesh, bl) - geometry_index(mesh, tr) + mesh.index(tl) + mesh.index(bl) + mesh.index(tr) + + mesh.index(tr) + mesh.index(bl) + mesh.index(br) + + +def draw(): + global mesh + global grid_size + global offset + global spacing + + camera_position(150.0, 150.0, 150.0) + camera_look_at( 0.0, 0.0, 0.0) + background(220, 200, 140) - geometry_index(mesh, tr) - geometry_index(mesh, bl) - geometry_index(mesh, br) + draw_mesh(mesh) - # TODO: this should happen implicitly on module load somehow diff --git a/crates/processing_pyo3/examples/box.py b/crates/processing_pyo3/examples/box.py index 28562be..32477b5 100644 --- a/crates/processing_pyo3/examples/box.py +++ b/crates/processing_pyo3/examples/box.py @@ -12,7 +12,6 @@ def draw(): camera_look_at(0.0, 0.0, 0.0) background(220) - push_matrix() rotate(angle) draw_box(100.0, 100.0, 100.0) diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 273e83f..5fd3a7d 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -35,6 +35,38 @@ impl Drop for Image { } } +#[pyclass(unsendable)] +pub struct Mesh { + entity: Entity, +} + +#[pymethods] +impl Mesh { + #[new] + pub fn new() -> PyResult { + let geometry = geometry_create(geometry::Topology::TriangleList) + .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; + Ok(Self { entity: geometry }) + } + + pub fn color(&self, r: f32, g: f32, b: f32, a: f32) -> PyResult<()> { + geometry_color(self.entity, r, g, b, a).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } + + pub fn normal(&self, nx: f32, ny: f32, nz: f32) -> PyResult<()> { + geometry_normal(self.entity, nx, ny, nz) + .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } + + pub fn vertex(&self, x: f32, y: f32, z: f32) -> PyResult<()> { + geometry_vertex(self.entity, x, y, z).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } + + pub fn index(&self, i: u32) -> PyResult<()> { + geometry_index(self.entity, i).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } +} + #[pyclass(unsendable)] pub struct Graphics { entity: Entity, @@ -179,6 +211,11 @@ impl Graphics { .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) } + pub fn draw_mesh(&self, mesh: &Mesh) -> PyResult<()> { + graphics_record_command(self.entity, DrawCommand::Geometry(mesh.entity)) + .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } + pub fn scale(&self, x: f32, y: f32) -> PyResult<()> { graphics_record_command(self.entity, DrawCommand::Scale { x, y }) .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 02ea67f..a394aa7 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -11,7 +11,7 @@ mod glfw; mod graphics; -use graphics::{Graphics, Image, get_graphics, get_graphics_mut}; +use graphics::{Graphics, Image, Mesh, get_graphics, get_graphics_mut}; use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyTuple}; use std::env; @@ -20,6 +20,7 @@ use std::env; fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; + m.add_class::()?; m.add_function(wrap_pyfunction!(size, m)?)?; m.add_function(wrap_pyfunction!(run, m)?)?; m.add_function(wrap_pyfunction!(mode_3d, m)?)?; @@ -37,6 +38,8 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(stroke_weight, m)?)?; m.add_function(wrap_pyfunction!(rect, m)?)?; m.add_function(wrap_pyfunction!(image, m)?)?; + m.add_function(wrap_pyfunction!(draw_mesh, m)?)?; + Ok(()) } @@ -151,6 +154,12 @@ fn draw_box(module: &Bound<'_, PyModule>, x: f32, y: f32, z: f32) -> PyResult<() get_graphics(module)?.draw_box(x, y, z) } +#[pyfunction] +#[pyo3(pass_module, signature = (mesh))] +fn draw_mesh(module: &Bound<'_, PyModule>, mesh: &Bound<'_, Mesh>) -> PyResult<()> { + get_graphics(module)?.draw_mesh(&*mesh.extract::>()?) +} + #[pyfunction] #[pyo3(pass_module, signature = (*args))] fn background(module: &Bound<'_, PyModule>, args: &Bound<'_, PyTuple>) -> PyResult<()> { From 47481871e2f5ecbde5a0404bffcfac16133a04d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Thu, 8 Jan 2026 21:25:35 -0500 Subject: [PATCH 5/8] animated_mesh.py works! --- crates/processing_pyo3/examples/animated_mesh.py | 12 ++++++++++++ crates/processing_pyo3/src/graphics.rs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/crates/processing_pyo3/examples/animated_mesh.py b/crates/processing_pyo3/examples/animated_mesh.py index c811a93..6519fb9 100644 --- a/crates/processing_pyo3/examples/animated_mesh.py +++ b/crates/processing_pyo3/examples/animated_mesh.py @@ -1,9 +1,11 @@ from processing import * +from math import sin, cos mesh = None grid_size = 20 spacing = 10.0 offset = (grid_size * spacing) / 2.0; +time = 0.0 def setup(): global mesh @@ -39,13 +41,23 @@ def draw(): global grid_size global offset global spacing + global time camera_position(150.0, 150.0, 150.0) camera_look_at( 0.0, 0.0, 0.0) background(220, 200, 140) + for z in range(grid_size): + for x in range(grid_size): + idx = int(z * grid_size + x) + px = x * spacing - offset + pz = z * spacing - offset + wave = sin(px * 0.1 + time) * cos(pz * 0.1 + time) * 20.0 + mesh.set_vertex(idx, px, wave, pz) + draw_mesh(mesh) + time += 0.05 # TODO: this should happen implicitly on module load somehow diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 5fd3a7d..2fd2fc5 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -65,6 +65,11 @@ impl Mesh { pub fn index(&self, i: u32) -> PyResult<()> { geometry_index(self.entity, i).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) } + + pub fn set_vertex(&self, i: u32, x: f32, y: f32, z: f32) -> PyResult<()> { + geometry_set_vertex(self.entity, i, x, y, z) + .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) + } } #[pyclass(unsendable)] From b75067dfbb919867ac7b9a040d58ad465f8a8600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sun, 11 Jan 2026 00:41:39 -0500 Subject: [PATCH 6/8] kwargs for `mesh` method and default topology --- crates/processing_pyo3/src/graphics.rs | 36 +++++++++++++++++++++++--- crates/processing_pyo3/src/lib.rs | 3 ++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 2fd2fc5..29f4cdf 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -1,6 +1,6 @@ use bevy::prelude::Entity; use processing::prelude::*; -use pyo3::{exceptions::PyRuntimeError, prelude::*}; +use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyDict}; use crate::glfw::GlfwContext; @@ -40,12 +40,40 @@ pub struct Mesh { entity: Entity, } +#[pyclass] +pub enum Topology { + PointList = 0, + LineList = 1, + LineStrip = 2, + TriangleList = 3, + TriangleStrip = 4, +} + +impl Topology { + pub fn as_u8(&self) -> u8 { + match self { + Self::PointList => 0, + Self::LineList => 1, + Self::LineStrip => 2, + Self::TriangleList => 3, + Self::TriangleStrip => 4, + } + } +} + #[pymethods] impl Mesh { #[new] - pub fn new() -> PyResult { - let geometry = geometry_create(geometry::Topology::TriangleList) - .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; + #[pyo3(signature = (**kwargs))] + pub fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult { + let topology = kwargs + .and_then(|k| k.get_item("topology").ok().flatten()) + .and_then(|t| t.cast_into::().ok()) + .and_then(|t| geometry::Topology::from_u8(t.borrow().as_u8())) + .unwrap_or(geometry::Topology::TriangleList); + + let geometry = + geometry_create(topology).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; Ok(Self { entity: geometry }) } diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index a394aa7..006e242 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -11,7 +11,7 @@ mod glfw; mod graphics; -use graphics::{Graphics, Image, Mesh, get_graphics, get_graphics_mut}; +use graphics::{Graphics, Image, Mesh, Topology, get_graphics, get_graphics_mut}; use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyTuple}; use std::env; @@ -21,6 +21,7 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; + m.add_class::()?; m.add_function(wrap_pyfunction!(size, m)?)?; m.add_function(wrap_pyfunction!(run, m)?)?; m.add_function(wrap_pyfunction!(mode_3d, m)?)?; From d4c2e5e105f057d218ac333ddd624ea27ffcd5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sun, 11 Jan 2026 13:19:52 -0500 Subject: [PATCH 7/8] Mesh -> Geometry --- .../processing_pyo3/examples/animated_mesh.py | 30 +++++++++---------- crates/processing_pyo3/src/graphics.rs | 8 ++--- crates/processing_pyo3/src/lib.rs | 12 ++++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/crates/processing_pyo3/examples/animated_mesh.py b/crates/processing_pyo3/examples/animated_mesh.py index 6519fb9..829f014 100644 --- a/crates/processing_pyo3/examples/animated_mesh.py +++ b/crates/processing_pyo3/examples/animated_mesh.py @@ -1,24 +1,24 @@ from processing import * from math import sin, cos -mesh = None +geometry = None grid_size = 20 spacing = 10.0 offset = (grid_size * spacing) / 2.0; time = 0.0 def setup(): - global mesh + global geometry size(800, 600) mode_3d() - mesh = Mesh() + geometry = Geometry() for z in range(grid_size): for x in range(grid_size): px = x * spacing - offset pz = z * spacing - offset - mesh.color(x/grid_size, 0.5, z/grid_size, 1.0) - mesh.normal(0.0, 1.0, 0.0) - mesh.vertex(px, 0.0, pz) + geometry.color(x/grid_size, 0.5, z/grid_size, 1.0) + geometry.normal(0.0, 1.0, 0.0) + geometry.vertex(px, 0.0, pz) for z in range(grid_size-1): for x in range(grid_size-1): @@ -27,17 +27,17 @@ def setup(): bl = (z + 1) * grid_size + x br = bl + 1 - mesh.index(tl) - mesh.index(bl) - mesh.index(tr) + geometry.index(tl) + geometry.index(bl) + geometry.index(tr) - mesh.index(tr) - mesh.index(bl) - mesh.index(br) + geometry.index(tr) + geometry.index(bl) + geometry.index(br) def draw(): - global mesh + global geometry global grid_size global offset global spacing @@ -53,9 +53,9 @@ def draw(): px = x * spacing - offset pz = z * spacing - offset wave = sin(px * 0.1 + time) * cos(pz * 0.1 + time) * 20.0 - mesh.set_vertex(idx, px, wave, pz) + geometry.set_vertex(idx, px, wave, pz) - draw_mesh(mesh) + draw_geometry(geometry) time += 0.05 diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 29f4cdf..5f7be05 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -36,7 +36,7 @@ impl Drop for Image { } #[pyclass(unsendable)] -pub struct Mesh { +pub struct Geometry { entity: Entity, } @@ -62,7 +62,7 @@ impl Topology { } #[pymethods] -impl Mesh { +impl Geometry { #[new] #[pyo3(signature = (**kwargs))] pub fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult { @@ -244,8 +244,8 @@ impl Graphics { .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) } - pub fn draw_mesh(&self, mesh: &Mesh) -> PyResult<()> { - graphics_record_command(self.entity, DrawCommand::Geometry(mesh.entity)) + pub fn draw_geometry(&self, geometry: &Geometry) -> PyResult<()> { + graphics_record_command(self.entity, DrawCommand::Geometry(geometry.entity)) .map_err(|e| PyRuntimeError::new_err(format!("{e}"))) } diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 006e242..6c475cf 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -11,7 +11,7 @@ mod glfw; mod graphics; -use graphics::{Graphics, Image, Mesh, Topology, get_graphics, get_graphics_mut}; +use graphics::{Graphics, Image, Geometry, Topology, get_graphics, get_graphics_mut}; use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyTuple}; use std::env; @@ -20,7 +20,7 @@ use std::env; fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; - m.add_class::()?; + m.add_class::()?; m.add_class::()?; m.add_function(wrap_pyfunction!(size, m)?)?; m.add_function(wrap_pyfunction!(run, m)?)?; @@ -39,7 +39,7 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(stroke_weight, m)?)?; m.add_function(wrap_pyfunction!(rect, m)?)?; m.add_function(wrap_pyfunction!(image, m)?)?; - m.add_function(wrap_pyfunction!(draw_mesh, m)?)?; + m.add_function(wrap_pyfunction!(draw_geometry, m)?)?; Ok(()) } @@ -156,9 +156,9 @@ fn draw_box(module: &Bound<'_, PyModule>, x: f32, y: f32, z: f32) -> PyResult<() } #[pyfunction] -#[pyo3(pass_module, signature = (mesh))] -fn draw_mesh(module: &Bound<'_, PyModule>, mesh: &Bound<'_, Mesh>) -> PyResult<()> { - get_graphics(module)?.draw_mesh(&*mesh.extract::>()?) +#[pyo3(pass_module, signature = (geometry))] +fn draw_geometry(module: &Bound<'_, PyModule>, geometry: &Bound<'_, Geometry>) -> PyResult<()> { + get_graphics(module)?.draw_geometry(&*geometry.extract::>()?) } #[pyfunction] From 75c18ef9a9bd27c56be25f5564580ea15fb20437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sun, 11 Jan 2026 15:11:47 -0500 Subject: [PATCH 8/8] fmt check --- crates/processing_pyo3/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 6c475cf..3985d24 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -11,7 +11,7 @@ mod glfw; mod graphics; -use graphics::{Graphics, Image, Geometry, Topology, get_graphics, get_graphics_mut}; +use graphics::{Geometry, Graphics, Image, Topology, get_graphics, get_graphics_mut}; use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyTuple}; use std::env;