diff --git a/README.md b/README.md index 31b94cf..f099154 100644 --- a/README.md +++ b/README.md @@ -110,14 +110,15 @@ See [development setup](docs/development.md) for prerequisites and checks. Ready-made canvases with two named 16:9 layers. Choose a size, then a format.
-Browse Full HD and UHD 4K templates — SVG, draw.io, JSON, CSV, DXF and HTML +Browse Full HD and UHD 4K templates — SVG, draw.io, PPTX, FIG, AI, JSON, CSV, DXF and HTML These starter files contain two named 16:9 layers on an exact pixel canvas. -- **Full HD — 1920 × 1080:** [SVG](docs/templates/midra-layout/midra-layout-1080p-2-layers.svg) · [draw.io](docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio) · [JSON](docs/templates/midra-layout/midra-layout-1080p-2-layers.json) · [CSV](docs/templates/midra-layout/midra-layout-1080p-2-layers.csv) · [DXF](docs/templates/midra-layout/midra-layout-1080p-2-layers.dxf) · [HTML](docs/templates/midra-layout/midra-layout-1080p-2-layers.html) -- **UHD 4K — 3840 × 2160:** [SVG](docs/templates/midra-layout/midra-layout-4k-2-layers.svg) · [draw.io](docs/templates/midra-layout/midra-layout-4k-2-layers.drawio) · [JSON](docs/templates/midra-layout/midra-layout-4k-2-layers.json) · [CSV](docs/templates/midra-layout/midra-layout-4k-2-layers.csv) · [DXF](docs/templates/midra-layout/midra-layout-4k-2-layers.dxf) · [HTML](docs/templates/midra-layout/midra-layout-4k-2-layers.html) +- **Full HD — 1920 × 1080:** [SVG](docs/templates/midra-layout/midra-layout-1080p-2-layers.svg) · [draw.io](docs/templates/midra-layout/midra-layout-1080p-2-layers.drawio) · [JSON](docs/templates/midra-layout/midra-layout-1080p-2-layers.json) · [CSV](docs/templates/midra-layout/midra-layout-1080p-2-layers.csv) · [DXF](docs/templates/midra-layout/midra-layout-1080p-2-layers.dxf) · [HTML](docs/templates/midra-layout/midra-layout-1080p-2-layers.html) · [PPTX](docs/templates/midra-layout/midra-layout-1080p-2-layers.pptx) · [Figma FIG](docs/templates/midra-layout/midra-layout-1080p-2-layers.fig) · [Illustrator AI](docs/templates/midra-layout/midra-layout-1080p-2-layers.ai) +- **UHD 4K — 3840 × 2160:** [SVG](docs/templates/midra-layout/midra-layout-4k-2-layers.svg) · [draw.io](docs/templates/midra-layout/midra-layout-4k-2-layers.drawio) · [JSON](docs/templates/midra-layout/midra-layout-4k-2-layers.json) · [CSV](docs/templates/midra-layout/midra-layout-4k-2-layers.csv) · [DXF](docs/templates/midra-layout/midra-layout-4k-2-layers.dxf) · [HTML](docs/templates/midra-layout/midra-layout-4k-2-layers.html) · [PPTX](docs/templates/midra-layout/midra-layout-4k-2-layers.pptx) · [Figma FIG](docs/templates/midra-layout/midra-layout-4k-2-layers.fig) · [Illustrator AI](docs/templates/midra-layout/midra-layout-4k-2-layers.ai) -Midra also imports/exports native PPTX and Figma FIG; Illustrator AI uses an optional +PPTX and FIG samples contain an editable slide/frame; AI samples were generated with +VectorCraft 0.24.1. Midra imports/exports Illustrator AI using an optional local VectorCraft CLI. See [formats, dependencies and licensing builds](docs/interfaces/midra-layout-exchange.md#optional-native-document-codecs-and-licensing-builds).
diff --git a/crates/midra-layout/examples/check_geometry_exchange.rs b/crates/midra-layout/examples/check_geometry_exchange.rs index a637922..6455986 100644 --- a/crates/midra-layout/examples/check_geometry_exchange.rs +++ b/crates/midra-layout/examples/check_geometry_exchange.rs @@ -123,7 +123,24 @@ fn main() -> Result<(), String> { println!("Verified {} layer boxes: {path}", shapes.len()); } } - [command, directory] if command == "templates" => { + [command, directory, extensions @ ..] if command == "templates" => { + use midra_layout::interchange::{self, Codec}; + let codecs = if extensions.is_empty() { + Codec::available() + .into_iter() + .filter(|c| !matches!(c, Codec::Pptx | Codec::Figma | Codec::Illustrator)) + .collect::>() + } else { + extensions + .iter() + .map(|extension| { + Codec::available() + .into_iter() + .find(|c| c.extension() == extension) + .ok_or_else(|| format!("Unsupported format in this build: {extension}")) + }) + .collect::, _>>()? + }; 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])] { @@ -133,14 +150,27 @@ fn main() -> Result<(), String> { .iter() .map(|layer| layer.id) .collect::>(); - for format in Format::ALL { - let contents = exchange::export(&project, &ids, format, Options::default())?; + for &format in &codecs { + let contents = interchange::export(&project, &ids, format, Options::default())?; + let filename = format!("midra-layout-{label}-2-layers.{}", format.extension()); + let pages = interchange::import(&contents, &filename)?; + if pages.len() != 1 + || pages[0] + .document + .shapes + .iter() + .map(|s| s.geometry) + .collect::>() + != project.layers.iter().map(|l| l.bounds).collect::>() + { + return Err(format!("Template round-trip mismatch: {filename}")); + } write_file( &directory.join(format!( "midra-layout-{label}-2-layers.{}", format.extension() )), - contents.as_bytes(), + &contents, true, )?; } @@ -148,7 +178,7 @@ fn main() -> Result<(), String> { } _ => { return Err( - "Usage: check_geometry_exchange generate DIRECTORY | templates DIRECTORY | verify FILE...".into(), + "Usage: check_geometry_exchange generate DIRECTORY | templates DIRECTORY [EXTENSION...] | native DIRECTORY EXTENSION... | verify FILE...".into(), ); } } diff --git a/crates/midra-layout/tests/exchange.rs b/crates/midra-layout/tests/exchange.rs index 3c4b5c0..8053ba7 100644 --- a/crates/midra-layout/tests/exchange.rs +++ b/crates/midra-layout/tests/exchange.rs @@ -449,3 +449,51 @@ fn exported_background_composites_visible_references_in_order() { assert_eq!(shapes.len(), 2); // one flattened background and one real layer assert!(shapes[0].background_only); } + +#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))] +fn check_native_templates(codecs: &[midra_layout::interchange::Codec]) { + use midra_layout::interchange; + for (label, resolution) in [("1080p", [1920, 1080]), ("4k", [3840, 2160])] { + let project = template(resolution); + let expected: Vec<_> = project.layers.iter().map(|l| l.bounds).collect(); + let ids: Vec<_> = project.layers.iter().map(|l| l.id).collect(); + for &codec in codecs { + let filename = format!("midra-layout-{label}-2-layers.{}", codec.extension()); + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../docs/templates/midra-layout") + .join(&filename); + let saved = std::fs::read(path).unwrap(); + let fresh = interchange::export(&project, &ids, codec, Options::default()).unwrap(); + // Native encoders may vary ZIP metadata or document IDs; compare imported geometry. + for bytes in [saved, fresh] { + let pages = interchange::import(&bytes, &filename).unwrap(); + assert_eq!(pages.len(), 1, "{filename}"); + assert!(pages[0].document.shapes.iter().all(|s| !s.background_only)); + assert_eq!( + pages[0] + .document + .shapes + .iter() + .map(|s| s.geometry) + .collect::>(), + expected, + "{filename}" + ); + } + } + } +} + +#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))] +#[test] +fn native_readme_templates_preserve_two_layer_geometry() { + use midra_layout::interchange::Codec; + check_native_templates(&[Codec::Pptx, Codec::Figma]); +} + +#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))] +#[test] +#[ignore = "Requires a real VectorCraft CLI; set MIDRA_VECTORCRAFT_CLI"] +fn illustrator_readme_templates_preserve_two_layer_geometry() { + check_native_templates(&[midra_layout::interchange::Codec::Illustrator]); +} diff --git a/docs/interfaces/midra-layout-exchange.md b/docs/interfaces/midra-layout-exchange.md index 78dfefe..6ac84fe 100644 --- a/docs/interfaces/midra-layout-exchange.md +++ b/docs/interfaces/midra-layout-exchange.md @@ -10,11 +10,27 @@ 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 the six text exchange formats. The 4K geometry is an exact +(3840 × 2160), in all nine exchange formats (including PPTX, FIG and AI). 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 +# Optional native codecs (default build); AI requires VectorCraft CLI: +MIDRA_VECTORCRAFT_CLI=/path/to/vectorcraft-cli cargo run --locked -p midra-layout --example check_geometry_exchange -- templates docs/templates/midra-layout pptx fig ai +``` + +The generator verifies imported geometry before writing each template and replaces +existing templates in the explicitly supplied directory. Samples contain only two +editable layer boxes, with no background or placeholder images. PPTX uses one slide, +FIG one frame, and AI one artboard. Their canvas sizes are pixels (PPTX uses the +documented 96 pixels/inch conversion). These files are geometry examples, not +full-fidelity project saves. AI samples were generated and round-trip checked with +VectorCraft CLI 0.24.1; Adobe Illustrator itself was not used for validation. +Native fixtures are checked semantically rather than byte-for-byte because encoder +metadata can vary. The AI regression check is opt-in and requires the real CLI: + +```sh +MIDRA_VECTORCRAFT_CLI=/path/to/vectorcraft-cli cargo test --locked -p midra-layout --test exchange illustrator_readme_templates -- --ignored ``` ## Application and format matrix @@ -297,7 +313,7 @@ the only positions present in that SVG. Include Midra Layout's background layer before exporting through draw.io when the full output-screen origin must survive the round trip. -Tests cover each format/artwork combination, all twelve published templates, +Tests cover each format/artwork combination, the twelve text templates and four native PPTX/FIG templates (plus two AI templates in the opt-in CLI check), full-screen layers vs backgrounds, negative/fractional coordinates, repeat round trips, compressed clipboard/files, embedded references, invalid IDs/versions and no-overwrite file handling. diff --git a/docs/midralayout/changelog.md b/docs/midralayout/changelog.md index 50346f6..576546f 100644 --- a/docs/midralayout/changelog.md +++ b/docs/midralayout/changelog.md @@ -4,6 +4,8 @@ ## Unreleased +- Add README-linked two-layer PPTX, Figma FIG and Illustrator AI templates in Full HD and UHD 4K. Extend the template generator with format selection and import verification; test native fixture geometry, with AI checked through VectorCraft 0.24.1. + - Remove the redundant Copy coordinates button from the title header and right-align the device label. Existing copy commands remain available. - Move Menu from the title header to the toolbar immediately before Project, within the same wrapping group. diff --git a/docs/templates/midra-layout/midra-layout-1080p-2-layers.ai b/docs/templates/midra-layout/midra-layout-1080p-2-layers.ai new file mode 100644 index 0000000..724583d Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-1080p-2-layers.ai differ diff --git a/docs/templates/midra-layout/midra-layout-1080p-2-layers.fig b/docs/templates/midra-layout/midra-layout-1080p-2-layers.fig new file mode 100644 index 0000000..64eb3e3 Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-1080p-2-layers.fig differ diff --git a/docs/templates/midra-layout/midra-layout-1080p-2-layers.pptx b/docs/templates/midra-layout/midra-layout-1080p-2-layers.pptx new file mode 100644 index 0000000..117e2f9 Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-1080p-2-layers.pptx differ diff --git a/docs/templates/midra-layout/midra-layout-4k-2-layers.ai b/docs/templates/midra-layout/midra-layout-4k-2-layers.ai new file mode 100644 index 0000000..6f9120f Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-4k-2-layers.ai differ diff --git a/docs/templates/midra-layout/midra-layout-4k-2-layers.fig b/docs/templates/midra-layout/midra-layout-4k-2-layers.fig new file mode 100644 index 0000000..4125b98 Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-4k-2-layers.fig differ diff --git a/docs/templates/midra-layout/midra-layout-4k-2-layers.pptx b/docs/templates/midra-layout/midra-layout-4k-2-layers.pptx new file mode 100644 index 0000000..ea6d52e Binary files /dev/null and b/docs/templates/midra-layout/midra-layout-4k-2-layers.pptx differ