From 8769caec00f804a9489700d8bfe0bd2e36b35c54 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 14 Nov 2026 14:51:11 +0100 Subject: [PATCH] Add two-layer Full HD and 4K exchange templates --- README.md | 10 ++++ .../examples/check_geometry_exchange.rs | 45 +++++++++++++- crates/midra-layout/tests/exchange.rs | 59 ++++++++++++++++++- docs/interfaces/midra-layout-exchange.md | 9 +++ docs/midra-layout.md | 3 + docs/midralayout/changelog.md | 2 + .../midra-layout-1080p-2-layers.drawio | 4 ++ .../midra-layout-1080p-2-layers.svg | 5 ++ .../midra-layout-4k-2-layers.drawio | 4 ++ .../midra-layout/midra-layout-4k-2-layers.svg | 5 ++ 10 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio create mode 100644 docs/templates/midra-layout/midra-layout-1080p-2-layers.svg create mode 100644 docs/templates/midra-layout/midra-layout-4k-2-layers.drawio create mode 100644 docs/templates/midra-layout/midra-layout-4k-2-layers.svg diff --git a/README.md b/README.md index 0b09e6c..3f5738b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,16 @@ The reporter needs FFprobe (included in portable bundles); PDF generation is built in. The exporter needs DeckCraft for PPTX or PdfCraft for PDF input. Run source commands from the repository root; CLI tools support `--help`. +## Midra Layout templates + +These starter files contain two named 16:9 layers on an exact pixel canvas. +They can be opened in draw.io or imported into Midra Layout. + +| Output canvas | SVG | draw.io | +| --- | --- | --- | +| Full HD — 1920 × 1080 | [Download SVG](docs/templates/midra-layout/midra-layout-1080p-2-layers.svg) | [Download draw.io](docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio) | +| UHD 4K — 3840 × 2160 | [Download SVG](docs/templates/midra-layout/midra-layout-4k-2-layers.svg) | [Download draw.io](docs/templates/midra-layout/midra-layout-4k-2-layers.drawio) | + ## PPTX reporter visual guide **[Follow the illustrated PPTX reporter guide →](docs/user-guide.md)** diff --git a/crates/midra-layout/examples/check_geometry_exchange.rs b/crates/midra-layout/examples/check_geometry_exchange.rs index d2da127..128efcd 100644 --- a/crates/midra-layout/examples/check_geometry_exchange.rs +++ b/crates/midra-layout/examples/check_geometry_exchange.rs @@ -1,10 +1,26 @@ //! Manual native-editor round trip; all paths are explicit, no device access. use midra_layout::{ - Layout, + Geometry, Layout, exchange::{self, Format, Options}, import::parse_values, - project::{Project, write_file}, + project::{Project, Resolution, write_file}, }; + +fn template_project(resolution: [u32; 2]) -> Project { + let mut project = Project::from_layout(&Layout::default()); + let scale = resolution[0] as f64 / 1920.0; + project.output_resolution = Resolution::from(resolution); + for layer in &mut project.layers { + layer.bounds = Geometry { + x: layer.bounds.x * scale, + y: layer.bounds.y * scale, + width: layer.bounds.width * scale, + height: layer.bounds.height * scale, + }; + } + project +} + fn main() -> Result<(), String> { let args: Vec<_> = std::env::args().skip(1).collect(); match args.as_slice() { @@ -54,9 +70,32 @@ fn main() -> Result<(), String> { println!("Verified {} layer boxes: {path}", shapes.len()); } } + [command, directory] if command == "templates" => { + let directory = std::path::Path::new(directory); + std::fs::create_dir_all(directory).map_err(|e| e.to_string())?; + for (label, resolution) in [("1080p", [1920, 1080]), ("4k", [3840, 2160])] { + let project = template_project(resolution); + let ids = project + .layers + .iter() + .map(|layer| layer.id) + .collect::>(); + for format in [Format::Svg, Format::Drawio] { + let contents = exchange::export(&project, &ids, format, Options::default())?; + write_file( + &directory.join(format!( + "midra-layout-{label}-2-layers.{}", + format.extension() + )), + contents.as_bytes(), + false, + )?; + } + } + } _ => { return Err( - "Usage: check_geometry_exchange generate DIRECTORY | verify FILE...".into(), + "Usage: check_geometry_exchange generate DIRECTORY | templates DIRECTORY | verify FILE...".into(), ); } } diff --git a/crates/midra-layout/tests/exchange.rs b/crates/midra-layout/tests/exchange.rs index 553be60..7309426 100644 --- a/crates/midra-layout/tests/exchange.rs +++ b/crates/midra-layout/tests/exchange.rs @@ -3,7 +3,7 @@ use midra_layout::{ Geometry, Layout, exchange::{self, Format, Options}, import::parse_values, - project::Project, + project::{Project, Resolution}, }; use std::io::Write; @@ -25,6 +25,63 @@ fn fixture() -> Project { .unwrap(); Project::from_layout(&layout) } + +fn template(resolution: [u32; 2]) -> Project { + let mut project = Project::from_layout(&Layout::default()); + let scale = resolution[0] as f64 / 1920.0; + project.output_resolution = Resolution::from(resolution); + for layer in &mut project.layers { + layer.bounds.x *= scale; + layer.bounds.y *= scale; + layer.bounds.width *= scale; + layer.bounds.height *= scale; + } + project +} + +#[test] +fn readme_templates_match_the_exporter_and_contain_two_layers() { + for (resolution, svg, drawio) in [ + ( + [1920, 1080], + include_str!("../../../docs/templates/midra-layout/midra-layout-1080p-2-layers.svg"), + include_str!("../../../docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio"), + ), + ( + [3840, 2160], + include_str!("../../../docs/templates/midra-layout/midra-layout-4k-2-layers.svg"), + include_str!("../../../docs/templates/midra-layout/midra-layout-4k-2-layers.drawio"), + ), + ] { + let project = template(resolution); + let ids = project + .layers + .iter() + .map(|layer| layer.id) + .collect::>(); + for (format, documented) in [(Format::Svg, svg), (Format::Drawio, drawio)] { + assert_eq!( + exchange::export(&project, &ids, format, Options::default()).unwrap(), + documented + ); + let imported = parse_values(documented).unwrap(); + assert_eq!(imported.shapes.len(), 2); + assert!(imported.shapes.iter().all(|shape| !shape.background_only)); + assert_eq!( + imported + .shapes + .iter() + .map(|shape| shape.geometry) + .collect::>(), + project + .layers + .iter() + .map(|layer| layer.bounds) + .collect::>() + ); + } + } +} #[test] fn every_format_and_artwork_option_roundtrips_geometry_and_order() { let project = fixture(); diff --git a/docs/interfaces/midra-layout-exchange.md b/docs/interfaces/midra-layout-exchange.md index 436abe7..f7ba66a 100644 --- a/docs/interfaces/midra-layout-exchange.md +++ b/docs/interfaces/midra-layout-exchange.md @@ -6,6 +6,15 @@ preserve layer **visible-box geometry**, not sources, crop settings, zoom, pivot Midra links, locks, visibility, camera or selection. Pictures illustrate current cropping; importing a picture does not reconstruct its crop or source settings. +Ready-to-open two-layer templates are published under +`docs/templates/midra-layout/` for Full HD (1920 × 1080) and UHD 4K +(3840 × 2160), in both SVG v2 and draw.io v1. The 4K geometry is an exact 2× +scale of the Full HD layout. Regenerate them with: + +```sh +cargo run --locked -p midra-layout --example check_geometry_exchange -- templates docs/templates/midra-layout +``` + ## Scope, coordinates and artwork Both formats offer Current layer (exactly one selected), Selected layers, diff --git a/docs/midra-layout.md b/docs/midra-layout.md index be54c2a..aa15384 100644 --- a/docs/midra-layout.md +++ b/docs/midra-layout.md @@ -552,6 +552,9 @@ viewport preferences, and the embedded reference image. Apply pending edits before saving. Opening asks before replacing current work and starts a fresh undo history. Existing files require confirmation before replacement. +The root README links ready-to-open SVG and draw.io templates with two layers +for 1920 × 1080 and 3840 × 2160 output canvases. + **Project → Export → Export SVG / Export draw.io** offers **Current layer…**, **Selected layers…**, **Specific layer…**, **All layers…** and **Visible layers only…**. A current-layer export keeps its original screen position and full-screen diff --git a/docs/midralayout/changelog.md b/docs/midralayout/changelog.md index 8ca5083..ed27e1d 100644 --- a/docs/midralayout/changelog.md +++ b/docs/midralayout/changelog.md @@ -4,6 +4,8 @@ ## Unreleased +- Add README-linked two-layer SVG and draw.io templates for Full HD and UHD 4K, generated by the application exporter and checked byte-for-byte in regression tests. + - Import SVG rendered by draw.io Desktop, including its SVG 1.1 DOCTYPE, nested cell wrappers, symbol/image layers and generated label fallbacks. A background-preserved native 31.7.0 round trip was checked; draw.io's cropped SVG exports necessarily retain their rebased coordinates. - Add current-layer SVG and draw.io exports with optional embedded backgrounds and source-pattern placeholders; import native/compressed draw.io files. Round-trip tests cover scopes/artwork and whole-pixel geometry; draw.io Desktop 31.7.0 rendering and XML re-save were checked. Use JSON for full source/crop fidelity. diff --git a/docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio b/docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio new file mode 100644 index 0000000..7ba2b83 --- /dev/null +++ b/docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio @@ -0,0 +1,4 @@ + + + + diff --git a/docs/templates/midra-layout/midra-layout-1080p-2-layers.svg b/docs/templates/midra-layout/midra-layout-1080p-2-layers.svg new file mode 100644 index 0000000..a8d20cb --- /dev/null +++ b/docs/templates/midra-layout/midra-layout-1080p-2-layers.svg @@ -0,0 +1,5 @@ + +Midra Layout geometry +Slides +Presenter + diff --git a/docs/templates/midra-layout/midra-layout-4k-2-layers.drawio b/docs/templates/midra-layout/midra-layout-4k-2-layers.drawio new file mode 100644 index 0000000..9b20f1f --- /dev/null +++ b/docs/templates/midra-layout/midra-layout-4k-2-layers.drawio @@ -0,0 +1,4 @@ + + + + diff --git a/docs/templates/midra-layout/midra-layout-4k-2-layers.svg b/docs/templates/midra-layout/midra-layout-4k-2-layers.svg new file mode 100644 index 0000000..28ce8fd --- /dev/null +++ b/docs/templates/midra-layout/midra-layout-4k-2-layers.svg @@ -0,0 +1,5 @@ + +Midra Layout geometry +Slides +Presenter +