Files
Sylpheed/crates/sylpheed-formats/examples/rest_scale_of.rs
MechaCat02 ccd49ac31f fix(lint): clear the clippy gate across examples and tests
80 findings, not the 14 the first run showed -- clippy stops at the first
failing compilation unit, so `--keep-going` is what makes the list complete.

60 were machine-applicable (`cargo clippy --fix`). The rest by hand:

* five descending `sort_by` -> `sort_by_key(Reverse(..))`
* `chunks_exact(4)` on both sides of four zips, so the compared items stay
  `[u8; 4]` rather than one array against one slice
* three `type` aliases for the census maps and the captured-quad tuple
* `&PathBuf` -> `&Path` in two disc tests
* two range loops; one of them keeps `#[allow(needless_range_loop)]` with the
  reason -- the index is into a map's value, which changes each iteration
* the module doc list in `invert_capture` re-indented to markdown's rules
* `blit`'s eight arguments get `#[allow(too_many_arguments)]`, not a struct

One dead `let off = b.len();` in a `ratc` test is dropped rather than renamed.
The sibling test at :162 is the one that asserts an offset; if this one was
meant to as well, that is a test change and not a lint fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-12 16:42:41 +02:00

63 lines
2.1 KiB
Rust

//! 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 std::path::PathBuf;
use sylpheed_formats::{pak::PakArchive, ui_layout};
fn main() {
let root = PathBuf::from(std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC"));
let argv: Vec<String> = std::env::args().skip(1).collect();
let pak = argv
.iter()
.find(|a| a.parse::<usize>().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<usize> = 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} at 1x/2x of pivot*2",
"element", "pivot(w,h)", "sx%", "sy%", "drawn px"
);
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!();
}
}