M9: a .jam shape past the size cap draws its outline at the cap (#1808)

The REST reader caps every size at 1,000,000; the native outline was built
from the uncapped size, so it reached past its frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Model-Effort: Opus 5.5 drove and fixed
This commit is contained in:
Trevor BrownandClaude Opus 5.5 committed 2026-11-12 05:46:11 -05:00
1 parent 9e22cc7bc3
commit 7cb5af017d
3 files changed
+19 -1

No files matched your search

@@ -584,6 +584,21 @@ fn a_jam_diamond_is_a_native_shape_drawn_by_figcraft() {
assert_eq!(label.align_h, figcraft_doc::TextAlignH::Center);
}
/// A shape past the importer's size cap is drawn at the capped size, so its outline stays inside
/// its frame.
#[test]
fn a_jam_shape_past_the_size_cap_draws_its_outline_at_the_cap() {
let mut layer = shape_node("DIAMOND");
set(&mut layer, "size", xy(2_000_000.0, 2_000_000.0));
let (doc, warnings) = jam(layer);
let frame = named(&doc, "Board object");
assert_eq!(frame.board, Some(figcraft_doc::BoardItem::Shape { shape: figcraft_doc::BoardShape::Diamond }), "{warnings:?}");
assert_eq!((frame.width, frame.height), (1e6, 1e6));
let outline = doc.node(frame.children[0]).unwrap();
let NodeKind::Vector { network } = &outline.kind else { panic!("{:?}", outline.kind) };
assert_eq!(*network, figcraft_doc::VectorNetwork::from_path(&figcraft_doc::BoardShape::Diamond.path(1e6, 1e6)));
}
/// 23 of FigJam's 30 shape kinds have a FigCraft outline; the other 7 stay frames and say which.
#[test]
fn every_figjam_shape_kind_maps_or_stays_a_frame() {
+3
View File
@@ -135,6 +135,9 @@ impl<'a> Mapper<'a> {
if !(w.is_finite() && h.is_finite() && w > 0.0 && h > 0.0) {
return None;
}
// The REST reader caps every size; the outline is drawn at the capped size too, so it
// stays inside its frame.
let (w, h) = (w.min(crate::rest::props::MAX_SIZE), h.min(crate::rest::props::MAX_SIZE));
// Everything is valid: build the outline from the record's paints, then the frame.
let mut outline = Obj::new();
outline.insert("id".into(), json!(format!("{rest_id};generated0")));
+1 -1
View File
@@ -13,7 +13,7 @@ use serde_json::Value;
use super::Ctx;
/// Largest width/height/stroke/radius/spacing value taken from the file.
pub(super) const MAX_SIZE: f64 = 1e6;
pub(crate) const MAX_SIZE: f64 = 1e6;
/// Largest coordinate taken from the file.
pub(super) const MAX_COORD: f64 = 1e7;
/// Most entries read from any one list (paints, effects, dashes, grids…).