diff --git a/Cargo.toml b/Cargo.toml index 48fb261..fa82c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "blobfox-template" version = "0.1.0" edition = "2021" +default-run = "blobfox-template" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/species/blobfox/assets/snug.svg b/species/blobfox/assets/snug.svg new file mode 100644 index 0000000..a158918 --- /dev/null +++ b/species/blobfox/assets/snug.svg @@ -0,0 +1,49 @@ + + + blobfox_snug + + + + + + + + + + + + + + + + + + + + + + + + + Blobfox team (https://git.shadamethyst.xyz/adri326/blobfox), licensed under the Apache 2.0 License + + + blobfox_snug + + + Feuerfuchs + + + https://git.shadamethyst.xyz/adri326/blobfox + + + Shad Amethyst + + + + + + diff --git a/species/blobfox/templates/base-snug.mustache b/species/blobfox/templates/base-snug.mustache new file mode 100644 index 0000000..b94b3c9 --- /dev/null +++ b/species/blobfox/templates/base-snug.mustache @@ -0,0 +1,7 @@ + + {{! TODO: update to the latest standard }} + {{#snug}}#left-ear{{/snug}} + {{#snug}}#right-ear{{/snug}} + {{#snug}}#right-ear-fluff{{/snug}} + {{#snug}}#body{{/snug}} + diff --git a/species/blobfox/templates/eyes-snug.mustache b/species/blobfox/templates/eyes-snug.mustache new file mode 100644 index 0000000..231190e --- /dev/null +++ b/species/blobfox/templates/eyes-snug.mustache @@ -0,0 +1,4 @@ + + {{#snug}}#left-eye{{/snug}} + {{#snug}}#right-eye{{/snug}} + diff --git a/species/blobfox/templates/nose-snug.mustache b/species/blobfox/templates/nose-snug.mustache new file mode 100644 index 0000000..f307896 --- /dev/null +++ b/species/blobfox/templates/nose-snug.mustache @@ -0,0 +1,4 @@ + + {{#snug}}#nose{{/snug}} + {{#snug}}#nose-outline{{/snug}} + diff --git a/species/blobfox/templates/tail-snug.mustache b/species/blobfox/templates/tail-snug.mustache new file mode 100644 index 0000000..fd1cbac --- /dev/null +++ b/species/blobfox/templates/tail-snug.mustache @@ -0,0 +1,4 @@ + + {{#snug}}#tail{{/snug}} + {{#snug}}#tail-outline{{/snug}} + diff --git a/species/blobfox/variants/snug.mustache b/species/blobfox/variants/snug.mustache new file mode 100644 index 0000000..9cce27d --- /dev/null +++ b/species/blobfox/variants/snug.mustache @@ -0,0 +1,10 @@ +{{>header}} + + {{>base-snug}} + {{>tail-snug}} + + + {{>eyes-snug}} + {{>nose-snug}} + +{{>footer}} diff --git a/species/blobfox/variants/snug_aww.mustache b/species/blobfox/variants/snug_aww.mustache new file mode 100644 index 0000000..70431a1 --- /dev/null +++ b/species/blobfox/variants/snug_aww.mustache @@ -0,0 +1,10 @@ +{{>header}} + + {{>base-snug}} + {{>tail-snug}} + + + {{>eyes-aww}} + {{>nose-aww}} + +{{>footer}} diff --git a/src/bin/clean.rs b/src/bin/clean.rs new file mode 100644 index 0000000..0b9aefd --- /dev/null +++ b/src/bin/clean.rs @@ -0,0 +1,69 @@ +use xmltree::{XMLNode, Element}; +use clap::Parser; +use std::collections::HashMap; +use std::path::PathBuf; + +fn main() { + let args = Args::parse(); + + for path in args.files { + let file = std::fs::File::open(path.clone()).unwrap_or_else(|err| { + panic!("Error while reading {}: {}", path.display(), err); + }); + let mut element = Element::parse(file).expect("Couldn't parse SVG!"); + + clean(&mut element); + + let mut s: Vec = Vec::new(); + element.write(&mut s).expect("Couldn't export SVG!"); + + std::fs::write(path.clone(), s).unwrap_or_else(|err| { + panic!("Error while writing {}: {}", path.display(), err); + }); + } +} + +fn clean(element: &mut Element) { + let mut counts: HashMap = HashMap::new(); + + fn count_rec(element: &Element, counts: &mut HashMap) { + if let Some(label) = element.attributes.get("label") { + if let Some(count) = counts.get_mut(label) { + *count += 1; + } else { + counts.insert(label.to_string(), 1); + } + } + + for child in element.children.iter() { + if let XMLNode::Element(ref child) = child { + count_rec(child, counts); + } + } + } + + count_rec(element, &mut counts); + + fn update_rec(element: &mut Element, counts: &HashMap) { + if let Some(label) = element.attributes.get("label") { + if let Some(1) = counts.get(label) { + element.attributes.insert("id".to_string(), label.to_string()); + } + } + + for child in element.children.iter_mut() { + if let XMLNode::Element(ref mut child) = child { + update_rec(child, counts); + } + } + } + + update_rec(element, &counts); +} + +#[derive(Parser)] +#[clap(author, version, about, long_about = None)] +struct Args { + #[clap(value_parser)] + files: Vec, +} diff --git a/vector/blobfox_snug.svg b/vector/blobfox_snug.svg index 1be4320..d1430df 100644 --- a/vector/blobfox_snug.svg +++ b/vector/blobfox_snug.svg @@ -1,118 +1,50 @@ - -blobfox_snugBlobfox team (https://git.shadamethyst.xyz/adri326/blobfox), licensed under the Apache 2.0 Licenseblobfox_snugFeuerfuchshttps://git.shadamethyst.xyz/adri326/blobfoxShad Amethyst + + blobfox_snug + + + + + + + + + + + + + + + + + + + + + + + + + Blobfox team (https://git.shadamethyst.xyz/adri326/blobfox), licensed under the Apache 2.0 License + + + blobfox_snug + + + Feuerfuchs + + + https://git.shadamethyst.xyz/adri326/blobfox + + + Shad Amethyst + + + + + +