From e747bff42525c7e6fde01bea4651db0dc7a94ae6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 30 Oct 2026 22:02:08 -0700 Subject: [PATCH] Shape Fill: the gradient help lists every kind and key the command takes The shape.fill params doc listed only linear and radial gradients with stops, angle and kind. The command also takes the rectangular and path kinds, focus and rotateWithShape. The doc now names them, and a test checks the doc's gradient keys and kinds against what the command reads. --- crates/engine/src/cmd/shape.rs | 2 +- crates/engine/src/tests.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/shape.rs b/crates/engine/src/cmd/shape.rs index 9565cdf7..08ed9be6 100644 --- a/crates/engine/src/cmd/shape.rs +++ b/crates/engine/src/cmd/shape.rs @@ -103,7 +103,7 @@ pub fn specs() -> Vec { "Shape Fill", ["Shape Format", "Shape Styles"], None, - "{color? | none?: true | background?: true (the slide background shows through; shapes and text boxes only) | gradient?: {stops: [[pos, color]], angle?, kind?: linear|radial} | picture?: base64 | pattern?: {preset, fg, bg} | transparency?: 0..1 | reset?: true, ids?}; pictureProps?: {tile?: bool, offsetX?, offsetY?: pt, scaleX?, scaleY?: 0..10, align?: tl|t|tr|l|ctr|r|bl|b|br, mirror?: none|x|y|xy, stretch?: [l, t, r, b] fractions, rotateWithShape?: bool} adjusts a picture fill; a group also formats its members", + "{color? | none?: true | background?: true (the slide background shows through; shapes and text boxes only) | gradient?: {stops: [[pos 0..1, color]], kind?: linear|radial|rectangular|path, angle?: deg (linear), focus?: [l, t, r, b] fractions (radial, rectangular and path: where the first stop sits), rotateWithShape?: bool} | picture?: base64 | pattern?: {preset, fg, bg} | transparency?: 0..1 | reset?: true, ids?}; pictureProps?: {tile?: bool, offsetX?, offsetY?: pt, scaleX?, scaleY?: 0..10, align?: tl|t|tr|l|ctr|r|bl|b|br, mirror?: none|x|y|xy, stretch?: [l, t, r, b] fractions, rotateWithShape?: bool} adjusts a picture fill; a group also formats its members", has_selection, fill ), diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 85cbe9d8..1fc7fb2d 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -4281,6 +4281,38 @@ fn a_params_doc_spells_out_each_parameter() { ); } +/// `shape.fill`'s params doc names each key and kind its `gradient` takes. +#[test] +fn shape_fill_documents_each_gradient_key_and_kind() { + use deckcraft_model::style::GradientShape; + let params = cmd::parse_params(find_command("shape.fill").unwrap().params).unwrap(); + let about = params.iter().find(|p| p.name == "gradient").unwrap().about; + assert_eq!(cmd::param_keys(about).unwrap(), ["stops", "kind", "angle", "focus", "rotateWithShape"]); + for kind in ["linear", "radial", "rectangular", "path"] { + assert!(about.contains(kind), "{kind}: {about}"); + let g = cmd::shape::gradient_param(&json!({ + "stops": [[0, "#ffffff"], [1, "#000000"]], + "kind": kind, + "angle": 30, + "focus": [0, 0, 1, 1], + "rotateWithShape": false + })) + .unwrap(); + assert!(!g.rotate_with_shape, "{kind}"); + match g.shape { + GradientShape::Linear { angle, .. } => assert_eq!((kind, angle), ("linear", 30.0)), + GradientShape::Path { path, focus } => { + let expected = match kind { + "radial" => "circle", + "rectangular" => "rect", + _ => "shape", + }; + assert_eq!((path.as_str(), focus), (expected, [0.0, 0.0, 1.0, 1.0]), "{kind}"); + } + } + } +} + #[test] fn what_a_command_acts_on_names_only_keys_it_takes() { for c in command_specs() {