Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Glow Range: document the 1..100 % range its slider and clamp use

Hector Villarreal21cca70465a0
diff --git a/crates/engine/src/layer_style.rs b/crates/engine/src/layer_style.rs
index bfaa756eb..cf1b4de82 100644
--- a/crates/engine/src/layer_style.rs
+++ b/crates/engine/src/layer_style.rs
@@ -1002,12 +1002,12 @@ pub fn specs() -> Vec<CommandSpec> {
style_cmd!(
"outerGlow",
"Outer Glow…",
- r##"{"color":"#rrggbb","opacity":0..100=75,"blend":str="screen","technique":"softer|precise","spread":0..100,"size":px,"range":0..100,"contour":name|curve,"antiAlias":bool,"noise":0..100,"add":bool}"##
+ r##"{"color":"#rrggbb","opacity":0..100=75,"blend":str="screen","technique":"softer|precise","spread":0..100,"size":px,"range":1..100=50,"contour":name|curve,"antiAlias":bool,"noise":0..100,"add":bool}"##
),
style_cmd!(
"innerGlow",
"Inner Glow…",
- r##"{"color":"#rrggbb","opacity":0..100=75,"blend":str="screen","technique":"softer|precise","source":"edge|center","choke":0..100,"size":px,"range":0..100,"contour":name|curve,"antiAlias":bool,"noise":0..100,"add":bool}"##
+ r##"{"color":"#rrggbb","opacity":0..100=75,"blend":str="screen","technique":"softer|precise","source":"edge|center","choke":0..100,"size":px,"range":1..100=50,"contour":name|curve,"antiAlias":bool,"noise":0..100,"add":bool}"##
),
style_cmd!(
"stroke",
@@ -1144,6 +1144,26 @@ mod tests {
assert_eq!((t.name.as_str(), t.depth, t.invert), ("Bubbles", -2.0, true));
}
+ /// #6698 review: a glow's Range runs 1..100 %, as its slider and Photoshop's do. A 0 is
+ /// held at the 1 % floor, and 100 is kept.
+ #[test]
+ fn glow_range_is_held_to_one_through_one_hundred() {
+ for kind in ["outerGlow", "innerGlow"] {
+ for (sent, kept) in [(0.0, 0.01), (-5.0, 0.01), (1.0, 0.01), (50.0, 0.5), (100.0, 1.0), (250.0, 1.0)] {
+ let mut s = session();
+ s.execute(&format!("layer.layerStyle.{kind}"), json!({"range": sent})).unwrap();
+ let range = match &effects(&s)[0] {
+ Effect::OuterGlow(g) | Effect::InnerGlow(g) => g.range,
+ other => panic!("{other:?}"),
+ };
+ assert!((range - kept).abs() < 1e-6, "{kind} range {sent} kept as {range}, not {kept}");
+ }
+ }
+ let doc = |id: &str| specs().into_iter().find(|c| c.id == id).map(|c| c.params).unwrap_or_default();
+ assert!(doc("layer.layerStyle.outerGlow").contains(r#""range":1..100=50"#));
+ assert!(doc("layer.layerStyle.innerGlow").contains(r#""range":1..100=50"#));
+ }
+
#[test]
fn every_style_command_adds_its_effect() {
for kind in ["dropShadow", "innerShadow", "outerGlow", "innerGlow", "stroke", "colorOverlay", "gradientOverlay", "bevelEmboss", "satin"] {