pub fn encode_svg(koi_frame: &KoiFrame) -> StringExpand description
Encode a self-contained SVG at the static export size with native pixel coordinates. Equal neighboring pixels share a rectangle within their row. Transparent pixels are omitted; visible pixels retain their color and alpha. Identical frames produce identical documents without I/O, timestamps, external assets, or input mutation.
Examples found in repository?
examples/generate-library.rs (line 323)
308fn render_sample(
309 output_directory: &Path,
310 koi_development: &KoiDevelopment,
311 koi_body: KoiBody,
312 file_stem: &str,
313 heading: &str,
314 index_markdown: &mut String,
315) -> Result<KoiFrame, Box<dyn Error>> {
316 let koi_frame = render_koi(koi_development, koi_body);
317 let file_name = format!("{file_stem}.png");
318 write_artifact(output_directory, &file_name, &encode_png(&koi_frame)?)?;
319 let svg_name = format!("{file_stem}.svg");
320 write_artifact(
321 output_directory,
322 &svg_name,
323 encode_svg(&koi_frame).as_bytes(),
324 )?;
325 index_markdown.push_str(&format!(
326 "### {heading}\n\n\n\n[SVG]({svg_name})\n\n"
327 ));
328 Ok(koi_frame)
329}