//! The resting SCALE of each element, so a drawn quad's size can be predicted. //! //! One additive draw on both the main menu and `EXTRAS` measures 819.2 x 720 px //! and matches no sprite at 1x or 2x. Scale is the missing factor: the keyframe //! carries scale_x / scale_y in percent, and a sprite drawn at 200 % x 500 % is //! nothing like its stored size. //! //! cargo run -p sylpheed-formats --example rest_scale_of -- 5 6 4 use sylpheed_formats::{pak::PakArchive, ui_layout}; use std::path::PathBuf; fn main() { let root = PathBuf::from(std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC")); let argv: Vec = std::env::args().skip(1).collect(); let pak = argv.iter().find(|a| a.parse::().is_err()) .cloned().unwrap_or_else(|| "GP_TITLE".to_string()); let ar = PakArchive::open(root.join(format!("dat/{pak}.pak"))).expect("pak"); let builds: Vec = argv.iter().filter_map(|a| a.parse().ok()).collect(); for build in if builds.is_empty() { vec![5usize, 6] } else { builds } { let Ok(by) = ar.read(&ar.entries()[build]) else { continue }; let Some(b) = ui_layout::parse_build(&by) else { continue }; println!("=== {pak} entry {build} ==="); println!("{:<22} {:>10} {:>7} {:>7} {:>12} {}", "element", "pivot(w,h)", "sx%", "sy%", "drawn px", "at 1x/2x of pivot*2"); for e in &b.elements { let k = match e.rest() { Some(k) => k, None => continue }; let w = e.pivot_x * 2; let h = e.pivot_y * 2; let dw = w as f64 * k.scale_x as f64 / 100.0; let dh = h as f64 * k.scale_y as f64 / 100.0; println!("{:<22} {:>4},{:<5} {:>7} {:>7} {:>6.1}x{:<5.1} {:>6.1}x{:<5.1}", e.name, w, h, k.scale_x, k.scale_y, dw, dh, dw * 2.0, dh * 2.0); } println!(); } }