From ba3835342f8606c6758e737a400303c4b1ce0da0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 00:16:28 +0000 Subject: [PATCH 1/5] Use shared XFL shape and media schema --- Cargo.lock | 5 +- Cargo.toml | 4 +- crates/xfl/src/import.rs | 140 ++++++++++++++++++++++----------------- crates/xml/Cargo.toml | 1 + crates/xml/src/lib.rs | 16 +++++ 5 files changed, 100 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4ec8108..fb63097b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,6 +420,7 @@ dependencies = [ name = "anicraft-xml" version = "0.3.0" dependencies = [ + "craft-xfl", "craft-xml", "thiserror 2.0.21", ] @@ -1318,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-xfl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=136b29dd76923d7d95d88ef48d5bd7c8da5576d8#136b29dd76923d7d95d88ef48d5bd7c8da5576d8" +source = "git+https://github.com/storytold/craft-libs?rev=bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a#bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" dependencies = [ "craft-xml", "miniz_oxide 0.8.9", @@ -1328,7 +1329,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=136b29dd76923d7d95d88ef48d5bd7c8da5576d8#136b29dd76923d7d95d88ef48d5bd7c8da5576d8" +source = "git+https://github.com/storytold/craft-libs?rev=bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a#bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" dependencies = [ "quick-xml 0.41.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index f2e1b674..9f9509dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-webp = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } -craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "136b29dd76923d7d95d88ef48d5bd7c8da5576d8" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "136b29dd76923d7d95d88ef48d5bd7c8da5576d8" } +craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" } # The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same # (default) features, so the tree keeps one wgpu build. wgpu = "30" diff --git a/crates/xfl/src/import.rs b/crates/xfl/src/import.rs index c9a10da9..cb021303 100644 --- a/crates/xfl/src/import.rs +++ b/crates/xfl/src/import.rs @@ -286,14 +286,13 @@ fn ramp(el: &X) -> Vec { } pub(crate) fn color(el: &X, key: &str, alpha_key: &str) -> Rgba { - let rgb = el.attr(key).and_then(|c| u32::from_str_radix(c.trim().trim_start_matches('#'), 16).ok()).unwrap_or(0); - Rgba::hex(rgb).with_alpha(el.f32(alpha_key).unwrap_or(1.0).clamp(0.0, 1.0)) + let parsed = craft_xfl::shape::color(el, key, alpha_key); + Rgba::hex(parsed.rgb).with_alpha(parsed.alpha) } fn matrix(el: &X) -> Affine { - let Some(m) = el.child("matrix").and_then(|m| m.child("Matrix")) else { return Affine::IDENTITY }; - let a = Affine { m: [m.f32("a").unwrap_or(1.0), m.f32("b").unwrap_or(0.0), m.f32("c").unwrap_or(0.0), m.f32("d").unwrap_or(1.0), m.f32("tx").unwrap_or(0.0), m.f32("ty").unwrap_or(0.0)] }; - if a.is_finite() { a } else { Affine::IDENTITY } + let m = craft_xfl::shape::matrix(el); + Affine { m: [m.a, m.b, m.c, m.d, m.tx, m.ty] } } /// Half the side of the square XFL gradients are defined on, in pixels (16384 twips / 20). @@ -302,19 +301,26 @@ const GRADIENT_HALF: f32 = 819.2; /// A fill definition (`SolidColor`, `LinearGradient`, `RadialGradient`, `BitmapFill`) as a /// paint. fn paint(def: &X, bitmaps: &HashMap, report: &mut Report) -> Option { - match def.name.as_str() { - "SolidColor" => Some(Paint::Solid(color(def, "color", "alpha"))), - "LinearGradient" | "RadialGradient" => { + let fill = craft_xfl::shape::Fill::new(def); + match fill.kind() { + craft_xfl::shape::FillKind::SolidColor => Some(Paint::Solid(color(def, "color", "alpha"))), + craft_xfl::shape::FillKind::LinearGradient | craft_xfl::shape::FillKind::RadialGradient => { let m = matrix(def); - let stops: Vec = def.children.iter().filter(|c| c.name == "GradientEntry").map(|g| GradientStop { offset: g.f32("ratio").unwrap_or(0.0).clamp(0.0, 1.0), color: color(g, "color", "alpha") }).collect(); + let stops: Vec = fill + .gradient_entries() + .map(|g| { + let color = g.color_value(); + GradientStop { offset: g.ratio().unwrap_or(0.0).clamp(0.0, 1.0), color: Rgba::hex(color.rgb).with_alpha(color.alpha) } + }) + .collect(); if stops.is_empty() { return None; } // Overflow, interpolation and the focal point carry over as they are (ADR 0074). - let spread = def.attr("spreadMethod").and_then(|s| Spread::from_key(s.trim())).unwrap_or_default(); - let linear_rgb = def.attr("interpolationMethod").is_some_and(|s| s.trim() == "linearRGB"); + let spread = fill.spread_method().and_then(|s| Spread::from_key(s.trim())).unwrap_or_default(); + let linear_rgb = fill.interpolation_method().is_some_and(|s| s.trim() == "linearRGB"); let frame = m.mul(&Affine::scale(GRADIENT_HALF, GRADIENT_HALF)); - let mut p = if def.name == "LinearGradient" { Paint::linear(Vec2::new(-1.0, 0.0), Vec2::new(1.0, 0.0), stops) } else { Paint::radial(Vec2::ZERO, 1.0, stops) }; + let mut p = if fill.kind() == craft_xfl::shape::FillKind::LinearGradient { Paint::linear(Vec2::new(-1.0, 0.0), Vec2::new(1.0, 0.0), stops) } else { Paint::radial(Vec2::ZERO, 1.0, stops) }; match &mut p { Paint::Linear { spread: s, linear_rgb: l, .. } => { *s = spread; @@ -323,14 +329,14 @@ fn paint(def: &X, bitmaps: &HashMap, report: &mut Report) -> O Paint::Radial { spread: s, linear_rgb: l, focal, .. } => { *s = spread; *l = linear_rgb; - *focal = def.f32("focalPointRatio").filter(|f| f.is_finite()).unwrap_or(0.0).clamp(-MAX_FOCAL, MAX_FOCAL); + *focal = fill.focal_point_ratio().unwrap_or(0.0).clamp(-MAX_FOCAL, MAX_FOCAL); } _ => {} } Some(p.with_frame(&frame, None)) } - "BitmapFill" => { - let Some(&bitmap) = def.attr("bitmapPath").and_then(|n| bitmaps.get(n)) else { + craft_xfl::shape::FillKind::Bitmap => { + let Some(&bitmap) = fill.bitmap_path().and_then(|n| bitmaps.get(n)) else { report.skip("bitmap fills of missing bitmaps"); return None; }; @@ -338,9 +344,9 @@ fn paint(def: &X, bitmaps: &HashMap, report: &mut Report) -> O let matrix = Affine { m: [m[0] / TWIPS, m[1] / TWIPS, m[2] / TWIPS, m[3] / TWIPS, m[4], m[5]] }; // Animate repeats a bitmap fill unless it is clipped (then the edge pixels extend, // which AniCraft draws as the image shown once). - Some(Paint::Bitmap { bitmap, repeat: !def.bool("bitmapIsClipped").unwrap_or(false), matrix }) + Some(Paint::Bitmap { bitmap, repeat: !fill.bitmap_is_clipped().unwrap_or(false), matrix }) } - _ => None, + craft_xfl::shape::FillKind::Other => None, } } @@ -348,39 +354,42 @@ fn paint(def: &X, bitmaps: &HashMap, report: &mut Report) -> O /// joints and miter limit, and the dashes of `DashedStroke` and dots of `DottedStroke` /// (ADR 0046). Ragged, stipple and hatched strokes are drawn solid. pub(crate) fn stroke(def: &X, bitmaps: &HashMap, report: &mut Report) -> Option { - if !matches!(def.name.as_str(), "SolidStroke" | "DashedStroke" | "DottedStroke" | "RaggedStroke" | "StippleStroke" | "HatchedStroke") { + let native = craft_xfl::shape::Stroke::new(def); + use craft_xfl::shape::StrokeKind as NativeStroke; + if native.kind() == NativeStroke::Other { return None; } // Round caps and joints are the format's default, and a miter limit of 3. - let cap = match def.attr("caps").map(str::trim) { + let cap = match native.caps().map(str::trim) { Some("none") => Cap::Butt, Some("square") => Cap::Square, _ => Cap::Round, }; - let join = match def.attr("joints").map(str::trim) { + let join = match native.joints().map(str::trim) { Some("miter") => Join::Miter, Some("bevel") => Join::Bevel, _ => Join::Round, }; - let miter_limit = def.f32("miterLimit").unwrap_or(anicraft_doc::stroke_style::DEFAULT_MITER_LIMIT); - let dash = match def.name.as_str() { - "DashedStroke" => Dash::dashed(def.f32("dash1").unwrap_or(6.0), def.f32("dash2").unwrap_or(3.0)), - "DottedStroke" => Dash::dotted(def.f32("dotSpace").unwrap_or(3.0)), - "SolidStroke" => None, + let miter_limit = native.miter_limit().unwrap_or(anicraft_doc::stroke_style::DEFAULT_MITER_LIMIT); + let dash = match native.kind() { + NativeStroke::Dashed => Dash::dashed(native.dash1().unwrap_or(6.0), native.dash2().unwrap_or(3.0)), + NativeStroke::Dotted => Dash::dotted(native.dot_space().unwrap_or(3.0)), + NativeStroke::Solid => None, _ => { report.skip("ragged, stipple and hatched strokes (drawn solid)"); None } }; let style = StrokeStyle { cap, join, miter_limit, dash }; - let width = def.f32("weight").unwrap_or(1.0).clamp(0.05, 1000.0); - let fill = def.child("fill").and_then(|f| f.children.first()); + let width = native.weight().unwrap_or(1.0).clamp(0.05, 1000.0); + let fill = native.fill(); let c = fill.map_or(Rgba::BLACK, |f| { - if f.name == "SolidColor" { - color(f, "color", "alpha") + if f.kind() == craft_xfl::shape::FillKind::SolidColor { + let value = f.color_value(); + Rgba::hex(value.rgb).with_alpha(value.alpha) } else { report.skip("gradient and bitmap strokes (drawn in one colour)"); - paint(f, bitmaps, report).map_or(Rgba::BLACK, |p| p.primary_color()) + paint(f.element(), bitmaps, report).map_or(Rgba::BLACK, |p| p.primary_color()) } }); Some(Stroke::new(c, width).with_style(style)) @@ -396,16 +405,23 @@ impl<'a> Builder<'a> { /// not a drawing object) is raw artwork: its shapes are marked to merge (ADR 0042), and the /// engine merges each keyframe's raw shapes into one drawing when it opens the file. fn shape(&mut self, el: &X, parent: &Affine, out: &mut Vec>, loose: bool) { + let Some(schema) = craft_xfl::shape::Shape::new(el) else { return }; let m = parent.mul(&matrix(el)); - let merge = loose && !el.bool("isDrawingObject").unwrap_or(false); - let fills: Vec<(u32, Option)> = el.list("fills").iter().map(|f| (f.u32("index").unwrap_or(0), f.children.first().and_then(|d| paint(d, &self.bitmaps, &mut self.report)))).collect(); - let strokes: Vec<(u32, Option)> = el.list("strokes").iter().map(|s| (s.u32("index").unwrap_or(0), s.children.first().and_then(|d| stroke(d, &self.bitmaps, &mut self.report)))).collect(); - let edges: Vec = el - .list("edges") - .iter() - .filter(|e| e.name == "Edge") - .map(|e| Edge { fill_left: e.u32("fillStyle0").unwrap_or(0), fill_right: e.u32("fillStyle1").unwrap_or(0), stroke: e.u32("strokeStyle").unwrap_or(0), segs: e.attr("edges").map(edges::parse).unwrap_or_default() }) - .collect(); + let merge = loose && !schema.is_drawing_object().unwrap_or(false); + let fills: Vec<(u32, Option)> = schema.fills().map(|style| { + let paint = style.definition().and_then(|definition| paint(definition.element(), &self.bitmaps, &mut self.report)); + (style.index().unwrap_or(0), paint) + }).collect(); + let strokes: Vec<(u32, Option)> = schema.strokes().map(|style| { + let stroke = style.definition().and_then(|definition| stroke(definition.element(), &self.bitmaps, &mut self.report)); + (style.index().unwrap_or(0), stroke) + }).collect(); + let edges: Vec = schema.edges().map(|edge| Edge { + fill_left: edge.fill_style0().unwrap_or(0), + fill_right: edge.fill_style1().unwrap_or(0), + stroke: edge.stroke_style().unwrap_or(0), + segs: edge.encoded_segments().map(edges::parse).unwrap_or_default(), + }).collect(); for (index, p) in fills { let (Some(p), true) = (p, index > 0) else { continue }; let path = edges::fill_path(&edges, index); @@ -894,14 +910,14 @@ impl<'a> Builder<'a> { /// `bin/`; either is used when it is a PNG or JPEG. Animate's own encodings of the data /// file are not public, so those bitmaps are reported instead. fn register_bitmaps(&mut self, root: &X) -> Result<(), XflError> { - for item in root.list("media").iter().filter(|i| i.name == "DOMBitmapItem").take(MAX_BITMAPS) { - let Some(name) = item.attr("name").filter(|n| !self.bitmaps.contains_key(*n)) else { continue }; + for item in craft_xfl::media::Catalog::new(root).bitmaps().take(MAX_BITMAPS) { + let Some(name) = item.name().filter(|n| !self.bitmaps.contains_key(*n)) else { continue }; let mut candidates = Vec::new(); - if let Some(href) = item.attr("href") { - candidates.push(format!("LIBRARY/{href}")); + if let Some(href) = item.href() { + candidates.push(craft_xfl::media::library_member(href)); } - if let Some(data) = item.attr("bitmapDataHRef") { - candidates.push(format!("bin/{data}")); + if let Some(data) = item.data_href() { + candidates.push(craft_xfl::media::data_member(data)); } let short: String = name.rsplit('/').next().unwrap_or(name).chars().take(256).collect(); let (mut found_data, mut unreadable) = (false, false); @@ -927,7 +943,7 @@ impl<'a> Builder<'a> { Some(mut b) => { b.id = BitmapId(self.doc.alloc_id()); // Animate leaves out the default (smoothing on in current versions). - b.smoothing = item.bool("allowSmoothing").unwrap_or(true); + b.smoothing = item.allow_smoothing().unwrap_or(true); self.place_in_folder(name, anicraft_doc::LibraryItem::Bitmap(b.id)); self.bitmaps.insert(name.to_string(), b.id); self.doc.bitmaps.push(Arc::new(b)); @@ -946,14 +962,14 @@ impl<'a> Builder<'a> { /// own encoding of the data file is not public, so those sounds are reported by name, as is /// every other sound that doesn't come across, with its format and why (ADR 0039). fn register_sounds(&mut self, root: &X) -> Result<(), XflError> { - for item in root.list("media").iter().filter(|i| i.name == "DOMSoundItem").take(MAX_SOUNDS) { - let Some(name) = item.attr("name").filter(|n| !self.sounds.contains_key(*n)) else { continue }; + for item in craft_xfl::media::Catalog::new(root).sounds().take(MAX_SOUNDS) { + let Some(name) = item.name().filter(|n| !self.sounds.contains_key(*n)) else { continue }; let mut candidates = Vec::new(); - if let Some(href) = item.attr("href") { - candidates.push((format!("LIBRARY/{href}"), false)); + if let Some(href) = item.href() { + candidates.push((craft_xfl::media::library_member(href), false)); } - if let Some(data) = item.attr("soundDataHRef") { - candidates.push((format!("bin/{data}"), true)); + if let Some(data) = item.data_href() { + candidates.push((craft_xfl::media::data_member(data), true)); } let short: String = name.rsplit('/').next().unwrap_or(name).chars().take(256).collect(); let shown: String = name.chars().take(256).collect(); @@ -1006,17 +1022,17 @@ impl<'a> Builder<'a> { /// original file (`href`, or `sourceExternalFilepath` inside the package) in `LIBRARY/`, then /// as its data file in `bin/` (`videoDataHRef`). fn register_videos(&mut self, root: &X) { - for item in root.list("media").iter().filter(|i| i.name == "DOMVideoItem").take(MAX_VIDEOS) { - let Some(name) = item.attr("name").filter(|n| !self.videos.contains_key(*n)) else { continue }; + for item in craft_xfl::media::Catalog::new(root).videos().take(MAX_VIDEOS) { + let Some(name) = item.name().filter(|n| !self.videos.contains_key(*n)) else { continue }; let mut candidates = Vec::new(); - if let Some(href) = item.attr("href") { - candidates.push(format!("LIBRARY/{href}")); + if let Some(href) = item.href() { + candidates.push(craft_xfl::media::library_member(href)); } - if let Some(src) = item.attr("sourceExternalFilepath").and_then(|p| p.strip_prefix("./")) { - candidates.push(src.replace('\\', "/")); + if let Some(path) = item.external_path().and_then(craft_xfl::media::packaged_external_member) { + candidates.push(path); } - if let Some(data) = item.attr("videoDataHRef") { - candidates.push(format!("bin/{data}")); + if let Some(data) = item.data_href() { + candidates.push(craft_xfl::media::data_member(data)); } let shown: String = name.chars().take(256).collect(); let short: String = name.rsplit('/').next().unwrap_or(name).chars().take(240).collect(); @@ -1043,8 +1059,8 @@ impl<'a> Builder<'a> { } } // Its length as the item gives it (seconds), else from its frames and rate. - let seconds = item.f32("length").filter(|s| s.is_finite() && *s >= 0.0).or_else(|| { - let (frames, fps) = (item.f32("frameCount")?, item.f32("fps")?); + let seconds = item.length().filter(|s| *s >= 0.0).or_else(|| { + let (frames, fps) = (item.frame_count()?, item.frames_per_second()?); (frames.is_finite() && fps.is_finite() && fps > 0.0).then(|| frames.max(0.0) / fps) }); let length = seconds.map(|s| format!(", {:.1} s", s.min(1.0e7))).unwrap_or_default(); diff --git a/crates/xml/Cargo.toml b/crates/xml/Cargo.toml index 0a3519b1..810611d3 100644 --- a/crates/xml/Cargo.toml +++ b/crates/xml/Cargo.toml @@ -8,6 +8,7 @@ publish.workspace = true repository.workspace = true [dependencies] +craft-xfl.workspace = true craft-xml.workspace = true thiserror.workspace = true diff --git a/crates/xml/src/lib.rs b/crates/xml/src/lib.rs index 20fe62ab..d2d6f8e7 100644 --- a/crates/xml/src/lib.rs +++ b/crates/xml/src/lib.rs @@ -20,6 +20,22 @@ pub struct Element { pub text: String, } +impl craft_xfl::shape::XflElement for Element { + type Elements<'a> = std::slice::Iter<'a, Element>; + + fn local_name(&self) -> &str { + self.name.rsplit(':').next().unwrap_or(&self.name) + } + + fn attr(&self, name: &str) -> Option<&str> { + Element::attr(self, name) + } + + fn elements(&self) -> Self::Elements<'_> { + self.children.iter() + } +} + impl Element { pub fn attr(&self, name: &str) -> Option<&str> { self.attrs.get(name).map(String::as_str) From e2146490ccb06decabe64e69d86a5ec76a547658 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 00:20:40 +0000 Subject: [PATCH 2/5] Use shared XFL primitive schema --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- crates/xfl/src/import.rs | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb63097b..b747fbe5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-xfl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a#bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" +source = "git+https://github.com/storytold/craft-libs?rev=352a410332c1c1d53bbb358b47cfd53ce18579b4#352a410332c1c1d53bbb358b47cfd53ce18579b4" dependencies = [ "craft-xml", "miniz_oxide 0.8.9", @@ -1329,7 +1329,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a#bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" +source = "git+https://github.com/storytold/craft-libs?rev=352a410332c1c1d53bbb358b47cfd53ce18579b4#352a410332c1c1d53bbb358b47cfd53ce18579b4" dependencies = [ "quick-xml 0.41.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 9f9509dd..26100da4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-webp = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } -craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "bb9f9a95cc6e8780b1fef0fb9d684536d8b2230a" } +craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "352a410332c1c1d53bbb358b47cfd53ce18579b4" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "352a410332c1c1d53bbb358b47cfd53ce18579b4" } # The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same # (default) features, so the tree keeps one wgpu build. wgpu = "30" diff --git a/crates/xfl/src/import.rs b/crates/xfl/src/import.rs index cb021303..a669d2ff 100644 --- a/crates/xfl/src/import.rs +++ b/crates/xfl/src/import.rs @@ -440,16 +440,22 @@ impl<'a> Builder<'a> { /// Rectangle and oval primitives. fn primitive(&mut self, el: &X, parent: &Affine, out: &mut Vec>) { - let (x, y) = (el.f32("x").unwrap_or(0.0), el.f32("y").unwrap_or(0.0)); - let (w, h) = (el.f32("objectWidth").unwrap_or(0.0), el.f32("objectHeight").unwrap_or(0.0)); + let Some(primitive) = craft_xfl::shape::Primitive::new(el) else { return }; + let (x, y) = (primitive.x().unwrap_or(0.0), primitive.y().unwrap_or(0.0)); + let (w, h) = (primitive.width().unwrap_or(0.0), primitive.height().unwrap_or(0.0)); if !(w > 0.0 && h > 0.0) { return; } - let path = if el.name == "DOMOvalObject" { Path::ellipse(x + w / 2.0, y + h / 2.0, w / 2.0, h / 2.0) } else { Path::rounded_rect(x, y, w, h, el.f32("topLeftRadius").unwrap_or(0.0).max(0.0)) }; - let fill = el.child("fill").and_then(|f| f.children.first()).and_then(|d| paint(d, &self.bitmaps, &mut self.report)); - let stroke = el.child("stroke").and_then(|s| s.children.first()).and_then(|d| stroke(d, &self.bitmaps, &mut self.report)); + let path = if primitive.kind() == craft_xfl::shape::PrimitiveKind::Oval { + Path::ellipse(x + w / 2.0, y + h / 2.0, w / 2.0, h / 2.0) + } else { + Path::rounded_rect(x, y, w, h, primitive.top_left_radius().unwrap_or(0.0).max(0.0)) + }; + let fill = primitive.fill().and_then(|definition| paint(definition.element(), &self.bitmaps, &mut self.report)); + let stroke = primitive.stroke().and_then(|definition| stroke(definition.element(), &self.bitmaps, &mut self.report)); if fill.is_some() || stroke.is_some() { - let m = parent.mul(&matrix(el)); + let native = primitive.matrix(); + let m = parent.mul(&Affine { m: [native.a, native.b, native.c, native.d, native.tx, native.ty] }); out.push(self.element(ElementKind::Shape(Shape { path: Arc::new(path), fill, stroke, fill_rule: FillRule::NonZero, merge: false, warp: None }), m, ColorEffect::default())); } } From 905bc066804863ec77abe1c91bd1173651af7109 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 00:25:32 +0000 Subject: [PATCH 3/5] Refresh shared XFL candidate pin --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b747fbe5..c7adb151 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-xfl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=352a410332c1c1d53bbb358b47cfd53ce18579b4#352a410332c1c1d53bbb358b47cfd53ce18579b4" +source = "git+https://github.com/storytold/craft-libs?rev=e4eddc5fe55a2cced3854a14f1ef326a20ad449b#e4eddc5fe55a2cced3854a14f1ef326a20ad449b" dependencies = [ "craft-xml", "miniz_oxide 0.8.9", @@ -1329,7 +1329,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=352a410332c1c1d53bbb358b47cfd53ce18579b4#352a410332c1c1d53bbb358b47cfd53ce18579b4" +source = "git+https://github.com/storytold/craft-libs?rev=e4eddc5fe55a2cced3854a14f1ef326a20ad449b#e4eddc5fe55a2cced3854a14f1ef326a20ad449b" dependencies = [ "quick-xml 0.41.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 26100da4..9c44a0d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-webp = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } -craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "352a410332c1c1d53bbb358b47cfd53ce18579b4" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "352a410332c1c1d53bbb358b47cfd53ce18579b4" } +craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "e4eddc5fe55a2cced3854a14f1ef326a20ad449b" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "e4eddc5fe55a2cced3854a14f1ef326a20ad449b" } # The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same # (default) features, so the tree keeps one wgpu build. wgpu = "30" From 8b322e9b69e5c6608817a2350448052222876367 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 00:34:50 +0000 Subject: [PATCH 4/5] Refresh shared XFL matrix compatibility pin --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7adb151..d9f9f628 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-xfl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e4eddc5fe55a2cced3854a14f1ef326a20ad449b#e4eddc5fe55a2cced3854a14f1ef326a20ad449b" +source = "git+https://github.com/storytold/craft-libs?rev=d5a77b7dc1f8b6445f26581c0a4ea63de7d25186#d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" dependencies = [ "craft-xml", "miniz_oxide 0.8.9", @@ -1329,7 +1329,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e4eddc5fe55a2cced3854a14f1ef326a20ad449b#e4eddc5fe55a2cced3854a14f1ef326a20ad449b" +source = "git+https://github.com/storytold/craft-libs?rev=d5a77b7dc1f8b6445f26581c0a4ea63de7d25186#d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" dependencies = [ "quick-xml 0.41.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 9c44a0d1..81c5bb2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-webp = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } -craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "e4eddc5fe55a2cced3854a14f1ef326a20ad449b" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "e4eddc5fe55a2cced3854a14f1ef326a20ad449b" } +craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" } # The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same # (default) features, so the tree keeps one wgpu build. wgpu = "30" From b0e9a1dfad36aca42bf70ca917dff359506a8c25 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 01:25:19 +0000 Subject: [PATCH 5/5] Pin XFL importer to merged shared parser --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9f9f628..70ec825a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-xfl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d5a77b7dc1f8b6445f26581c0a4ea63de7d25186#d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" +source = "git+https://github.com/storytold/craft-libs?rev=0f59e325e5755a9524bc37dedc652fa215ca4d0c#0f59e325e5755a9524bc37dedc652fa215ca4d0c" dependencies = [ "craft-xml", "miniz_oxide 0.8.9", @@ -1329,7 +1329,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d5a77b7dc1f8b6445f26581c0a4ea63de7d25186#d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" +source = "git+https://github.com/storytold/craft-libs?rev=0f59e325e5755a9524bc37dedc652fa215ca4d0c#0f59e325e5755a9524bc37dedc652fa215ca4d0c" dependencies = [ "quick-xml 0.41.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 81c5bb2e..6a6254f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } craft-webp = { git = "https://github.com/storytold/craft-libs", rev = "f0f4758c01581d79577b9bf5046c06f4e77b1f18" } -craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "d5a77b7dc1f8b6445f26581c0a4ea63de7d25186" } +craft-xfl = { git = "https://github.com/storytold/craft-libs", rev = "0f59e325e5755a9524bc37dedc652fa215ca4d0c" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "0f59e325e5755a9524bc37dedc652fa215ca4d0c" } # The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same # (default) features, so the tree keeps one wgpu build. wgpu = "30"