multiavatar 1.0.10

Deterministic multicultural avatar generator — pure Rust port of multiavatar.js with SVG/PNG/JPEG/GIF/favicon/ICO/data-URI outputs; part library embedded in the binary, no runtime files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! 部件键解析器:把 0-47 的编号换算为「初始角色(00-15) + 颜色主题(A/B/C)」的部件键。
//!
//! 对应 multiavatar.js:`nr>31 → nr-32+'C';nr>15 → nr-16+'B';否则 nr+'A'`,
//! 其中角色号补零到两位。

use crate::util::two;

/// 编号 → 部件键(如 16 → "00B",35 → "03C",7 → "07A")。
pub fn resolve(nr: i32) -> String {
    let (base, theme) = if nr > 31 {
        (nr - 32, "C")
    } else if nr > 15 {
        (nr - 16, "B")
    } else {
        (nr, "A")
    };
    format!("{}{}", two(base), theme)
}