Skip to content

Commit ce61959

Browse files
committed
fix: clamp --glyph-edge-threshold to [0,2] and clarify --glyph-selection help
1 parent 9e0d038 commit ce61959

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/cli.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,9 @@ pub struct Args {
11311131
/// `None` means "use the per-preset render default" (mirror).
11321132
pub palette_cycle_mode: Option<String>,
11331133

1134-
/// Character-selection strategy: brightness ramp, shape matching, or Sobel
1135-
/// edge-orientation hybrid. TUI-only; affects Ascii/Braille/Sculpted.
1134+
/// Character-selection strategy (TUI/print only). `brightness` forces the
1135+
/// tonal ramp and `shape` the shape path on Ascii/Braille/Sculpted; `hybrid`
1136+
/// adds Sobel edge-orientation directional glyphs on Ascii only.
11361137
#[arg(long = "glyph-selection", value_name = "MODE")]
11371138
pub glyph_selection: Option<String>,
11381139

@@ -1997,7 +1998,7 @@ impl Args {
19971998
g.selection = Some(s.parse()?);
19981999
}
19992000
if let Some(t) = self.glyph_edge_threshold {
2000-
g.edge_threshold = t;
2001+
g.edge_threshold = t.clamp(0.0, 2.0);
20012002
}
20022003
Ok(g)
20032004
}
@@ -2981,6 +2982,20 @@ mod tests {
29812982
assert_eq!(art.glyph.edge_threshold, 0.3);
29822983
}
29832984

2985+
#[test]
2986+
fn glyph_edge_threshold_clamps_to_range() {
2987+
let mut args = Args::parse_from(["tslime"]);
2988+
args.glyph_selection = Some("hybrid".into());
2989+
args.glyph_edge_threshold = Some(5.0);
2990+
let art = args.to_render_art_defaults().unwrap();
2991+
assert_eq!(art.glyph.edge_threshold, 2.0);
2992+
2993+
let mut args = Args::parse_from(["tslime"]);
2994+
args.glyph_edge_threshold = Some(-1.0);
2995+
let art = args.to_render_art_defaults().unwrap();
2996+
assert_eq!(art.glyph.edge_threshold, 0.0);
2997+
}
2998+
29842999
#[test]
29853000
fn no_glyph_flags_stay_identity() {
29863001
let args = Args::parse_from(["tslime"]);

0 commit comments

Comments
 (0)