From 2b43d203d0e031048ee892e4fa1c840469c5043d Mon Sep 17 00:00:00 2001 From: Sara Hartse Date: Mon, 20 Mar 2023 10:00:25 -0700 Subject: [PATCH] Add optional z-scale argument, default to unscaled --- holocli/src/cli.rs | 4 ++++ holocli/src/main.rs | 2 +- holoscribe/src/lib.rs | 2 +- holoscribe/src/scriber/mod.rs | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/holocli/src/cli.rs b/holocli/src/cli.rs index 69b300d..6718d13 100644 --- a/holocli/src/cli.rs +++ b/holocli/src/cli.rs @@ -33,6 +33,10 @@ pub struct Args { /// The density of lines etched per mm. Defaults to 1. #[arg(long, default_value_t = 1)] pub stroke_density: usize, + + /// The scaling factor for translating z coordinates to circle radius + #[arg(long, default_value_t = 1.0)] + pub z_scale: f32, } /// Represents a size in millimeters diff --git a/holocli/src/main.rs b/holocli/src/main.rs index 0ba0ccf..757dedb 100644 --- a/holocli/src/main.rs +++ b/holocli/src/main.rs @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { let user_defined_model = ObjInterpolator::from_file(args.input).unwrap(); let interpolated_points = user_defined_model.interpolate_edges(args.stroke_density); - let circle_strat = scriber::CircleScriber::new(); + let circle_strat = scriber::CircleScriber::new(args.z_scale); let scriber = scriber::Scriber::new( circle_strat, (args.canvas_size.width, args.canvas_size.height), diff --git a/holoscribe/src/lib.rs b/holoscribe/src/lib.rs index 36bdbe9..219c7e5 100644 --- a/holoscribe/src/lib.rs +++ b/holoscribe/src/lib.rs @@ -22,7 +22,7 @@ mod tests { let model = ObjInterpolator::from_file("tests/icosahedron.obj".to_string()).expect("invalid model"); let interpolated_points = model.interpolate_edges(100); - let circle_strat = scriber::CircleScriber::new(); + let circle_strat = scriber::CircleScriber::new(1.0); let scriber = scriber::Scriber::new(circle_strat, (100, 100)); b.iter(|| scriber.scribe(&interpolated_points)); } diff --git a/holoscribe/src/scriber/mod.rs b/holoscribe/src/scriber/mod.rs index 8119eae..0804589 100644 --- a/holoscribe/src/scriber/mod.rs +++ b/holoscribe/src/scriber/mod.rs @@ -48,8 +48,8 @@ pub struct CircleScriber { } impl CircleScriber { - pub fn new() -> Self { - CircleScriber { z_scale_factor: 0.25 } + pub fn new(z_scale_factor: f32) -> Self { + CircleScriber { z_scale_factor } } }