Object styles: a stroke tint outside 0..1 is refused

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paaspaas00andClaude Opus 5.5 committed 2026-10-21 13:36:47 +02:00
1 parent 025db568cd
commit ef4bbdb708
2 files changed
+12 -5

No files matched your search

+8 -5
View File
@@ -1536,13 +1536,16 @@ fn create_object(s: &mut Session, p: &Value) -> Result<Value> {
}
/// `p.stroke` merged over `base` (as [`group_param`]), refused when the weight isn't a number ≥ 0
/// or the tint isn't finite.
/// or the tint isn't 0–1.
fn stroke_param(cmd: &str, p: &Value, base: Option<&designcraft_doc::Stroke>) -> Result<Option<Option<designcraft_doc::Stroke>>> {
let st = group_param(cmd, p, "stroke", base.unwrap_or(&designcraft_doc::Stroke::default()))?;
if let Some(Some(st)) = &st
&& !(st.weight.is_finite() && st.weight >= 0.0 && st.tint.is_finite())
{
return Err(bad(cmd, "stroke weight must be a number ≥ 0"));
if let Some(Some(st)) = &st {
if !(st.weight.is_finite() && st.weight >= 0.0) {
return Err(bad(cmd, "stroke weight must be a number ≥ 0"));
}
if !(0.0..=1.0).contains(&st.tint) {
return Err(bad(cmd, "stroke tint must be 0..1"));
}
}
Ok(st)
}
+4
View File
@@ -730,6 +730,10 @@ fn object_styles_carry_corners_and_their_stroke_and_corners_can_be_edited() {
for cmd in ["style.object.create", "style.object.edit"] {
let e = s.execute(cmd, &json!({"name": "Framed", "stroke": {"weight": -3}})).unwrap_err();
assert!(e.to_string().contains("stroke weight"), "{cmd}: {e}");
for tint in [-1.0, 1.5] {
let e = s.execute(cmd, &json!({"name": "Framed", "stroke": {"tint": tint}})).unwrap_err();
assert!(e.to_string().contains("stroke tint"), "{cmd}: {e}");
}
}
assert_eq!(s.doc().unwrap().doc.styles.object.len(), styles);
// null: the style stops setting corners, the items keep theirs.