Skip to main content

ishou_render/
svg.rs

1//! SVG renderer — stamps the brand mark (a swerve inside the viewbox) as a
2//! standalone SVG document. Variants: `mark`, `mark-mono-black`, `mark-mono-white`.
3
4use ishou_tokens::TokenSet;
5
6pub fn render(t: &TokenSet) -> String {
7    let b = &t.brand;
8    let vb = b.swerve.viewbox;
9    let stroke_cap = match b.swerve.stroke_cap {
10        ishou_tokens::brand::StrokeCap::Butt => "butt",
11        ishou_tokens::brand::StrokeCap::Round => "round",
12        ishou_tokens::brand::StrokeCap::Square => "square",
13    };
14    let ink = t.color.ink.hex();
15    let paper = t.color.paper.hex();
16    format!(
17        r#"<!-- ishou mark — pleme-io swerve (generated) -->
18<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {vb} {vb}" width="{vb}" height="{vb}">
19  <rect width="{vb}" height="{vb}" rx="{rx}" fill="{paper}"/>
20  <path d="{d}"
21        fill="none"
22        stroke="{ink}"
23        stroke-width="{sw}"
24        stroke-linecap="{stroke_cap}"
25        stroke-linejoin="round"/>
26</svg>
27"#,
28        vb = vb,
29        rx = vb / 10,
30        paper = paper,
31        ink = ink,
32        d = b.swerve.path_d,
33        sw = b.swerve.stroke_width,
34        stroke_cap = stroke_cap,
35    )
36}