Skip to content

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

Merge PR #7636: Show Technique and Range in the glow Layer Style pages (#6698)

aionggc5630b2a5d70
diff --cc crates/engine/src/layer_style.rs
index 602cf0694,cf1b4de82..1647e8782
--- a/crates/engine/src/layer_style.rs
+++ b/crates/engine/src/layer_style.rs
@@@ -86,12 -86,12 +86,12 @@@ pub fn effect_defaults(kind: &str) -> V
json!({"blend": "Multiply", "color": "#000000", "opacity": 75, "angle": 120, "useGlobalLight": true, "distance": 5, "choke": 0, "size": 5, "contour": "Linear", "antiAlias": false, "noise": 0})
}
"outerGlow" => {
- json!({"blend": "Screen", "opacity": 75, "color": "#ffffbe", "spread": 0, "size": 5, "range": 50, "contour": "Linear", "antiAlias": false, "noise": 0})
+ json!({"blend": "Screen", "opacity": 75, "color": "#ffffbe", "technique": "softer", "spread": 0, "size": 5, "range": 50, "contour": "Linear", "antiAlias": false, "noise": 0})
}
"innerGlow" => {
- json!({"blend": "Screen", "opacity": 75, "color": "#ffffbe", "source": "edge", "choke": 0, "size": 5, "contour": "Linear", "antiAlias": false, "noise": 0})
+ json!({"blend": "Screen", "opacity": 75, "color": "#ffffbe", "technique": "softer", "source": "edge", "choke": 0, "size": 5, "range": 50, "contour": "Linear", "antiAlias": false, "noise": 0})
}
- "stroke" => json!({"size": 3, "position": "outside", "blend": "Normal", "opacity": 100, "color": "#000000"}),
+ "stroke" => json!({"size": 1, "position": "inside", "blend": "Normal", "opacity": 100, "overprint": false, "color": "#000000"}),
"colorOverlay" => json!({"blend": "Normal", "color": "#ff0000", "opacity": 100}),
"gradientOverlay" => {
json!({"blend": "Normal", "opacity": 100, "from": "#000000", "to": "#ffffff", "reverse": false, "style": "linear", "angle": 90, "scale": 100})
@@@ -1148,28 -1144,26 +1148,48 @@@ 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 bevel_gloss_anti_alias_is_a_param() {
+ let mut s = session();
+ s.execute("layer.layerStyle.bevelEmboss", json!({"glossContour": "Ring - Double", "glossAntiAlias": true})).unwrap();
+ let Effect::BevelEmboss(b) = &effects(&s)[0] else { panic!() };
+ assert!(b.gloss_anti_alias);
+ s.execute("layer.layerStyle.bevelEmboss", json!({"glossAntiAlias": false})).unwrap();
+ let Effect::BevelEmboss(b) = &effects(&s)[0] else { panic!() };
+ assert!(!b.gloss_anti_alias);
+ }
+
+ #[test]
+ fn stroke_overprint_is_a_param() {
+ let mut s = session();
+ s.execute("layer.layerStyle.stroke", json!({"size": 4, "overprint": true})).unwrap();
+ let Effect::Stroke(st) = &effects(&s)[0] else { panic!() };
+ assert!(st.overprint);
+ s.execute("layer.layerStyle.stroke", json!({"overprint": false})).unwrap();
+ let Effect::Stroke(st) = &effects(&s)[0] else { panic!() };
+ assert!(!st.overprint);
+ }
+
#[test]
fn every_style_command_adds_its_effect() {
for kind in ["dropShadow", "innerShadow", "outerGlow", "innerGlow", "stroke", "colorOverlay", "gradientOverlay", "bevelEmboss", "satin"] {