fix(avatar): prevent u16 overflow panic when seed byte is large

hue_color and accent_color computed (seed as u16) * 360, which overflows
u16 when seed >= 182 — debug builds panicked, release wrapped silently.
Widen to u32 before the multiplication.

This also unblocks several identity_manager tests that constructed avatars
through master_node_svg and were aborting on the panic.
This commit is contained in:
archipelago 2026-04-23 13:02:01 -04:00
parent f6efe2f356
commit 9d42645aa3

View File

@ -18,12 +18,12 @@ use base64::Engine;
/// Convert a byte to an HSL triple biased toward readable foregrounds on
/// dark backgrounds (saturation 6085%, lightness 5270%).
fn hue_color(seed: u8) -> String {
let hue = (seed as u16) * 360 / 256;
let hue = (seed as u32) * 360 / 256;
format!("hsl({}, 72%, 60%)", hue)
}
fn accent_color(seed: u8) -> String {
let hue = (seed as u16) * 360 / 256;
let hue = (seed as u32) * 360 / 256;
format!("hsl({}, 80%, 68%)", hue)
}