From 121934c4c3543768bca01e6b96522d59e10775a1 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Wed, 4 Sep 2024 12:58:55 -0700 Subject: [PATCH] Encapsulate construction --- app-proto/inversive-display/src/main.rs | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app-proto/inversive-display/src/main.rs b/app-proto/inversive-display/src/main.rs index f5b42c5..2042c08 100644 --- a/app-proto/inversive-display/src/main.rs +++ b/app-proto/inversive-display/src/main.rs @@ -83,6 +83,22 @@ fn bind_vertex_attrib( ); } +fn push_gen_test_construction( + sphere_vec: &mut Vec>, + construction_to_world: &DMatrix, + ctrl_x: f64, + ctrl_y: f64, + radius_x: f64, + radius_y: f64 +) { + sphere_vec.push(construction_to_world * engine::sphere(0.5, 0.5, ctrl_x, radius_x)); + sphere_vec.push(construction_to_world * engine::sphere(-0.5, -0.5, ctrl_y, radius_y)); + sphere_vec.push(construction_to_world * engine::sphere(-0.5, 0.5, 0.0, 0.75)); + sphere_vec.push(construction_to_world * engine::sphere(0.5, -0.5, 0.0, 0.5)); + sphere_vec.push(construction_to_world * engine::sphere(0.0, 0.15, 1.0, 0.25)); + sphere_vec.push(construction_to_world * engine::sphere(0.0, -0.15, -1.0, 0.25)); +} + fn main() { // set up a config option that forwards panic messages to `console.error` #[cfg(feature = "console_error_panic_hook")] @@ -292,12 +308,12 @@ fn main() { // update the construction sphere_vec.clear(); - sphere_vec.push(&construction_to_world * engine::sphere(0.5, 0.5, ctrl_x.get(), radius_x.get())); - sphere_vec.push(&construction_to_world * engine::sphere(-0.5, -0.5, ctrl_y.get(), radius_y.get())); - sphere_vec.push(&construction_to_world * engine::sphere(-0.5, 0.5, 0.0, 0.75)); - sphere_vec.push(&construction_to_world * engine::sphere(0.5, -0.5, 0.0, 0.5)); - sphere_vec.push(&construction_to_world * engine::sphere(0.0, 0.15, 1.0, 0.25)); - sphere_vec.push(&construction_to_world * engine::sphere(0.0, -0.15, -1.0, 0.25)); + push_gen_test_construction( + &mut sphere_vec, + &construction_to_world, + ctrl_x.get(), ctrl_y.get(), + radius_x.get(), radius_y.get() + ); // set the resolution let width = canvas.width() as f32;