diff --git a/species/blobfox/assets/flag_ace.svg b/species/blobfox/assets/flag_ace.svg new file mode 100644 index 0000000..38b0d58 --- /dev/null +++ b/species/blobfox/assets/flag_ace.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/species/blobfox/assets/flag_demisexual.svg b/species/blobfox/assets/flag_demisexual.svg new file mode 100644 index 0000000..8def0a5 --- /dev/null +++ b/species/blobfox/assets/flag_demisexual.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/species/blobfox/assets/flag_enby.svg b/species/blobfox/assets/flag_enby.svg new file mode 100644 index 0000000..43d87ab --- /dev/null +++ b/species/blobfox/assets/flag_enby.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/species/blobfox/assets/flag_pan.svg b/species/blobfox/assets/flag_pan.svg new file mode 100644 index 0000000..6a821d5 --- /dev/null +++ b/species/blobfox/assets/flag_pan.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/species/blobfox/assets/flag_progress.svg b/species/blobfox/assets/flag_progress.svg new file mode 100644 index 0000000..dd6ca14 --- /dev/null +++ b/species/blobfox/assets/flag_progress.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/species/blobfox/species.toml b/species/blobfox/species.toml index 7fe64c8..182813e 100644 --- a/species/blobfox/species.toml +++ b/species/blobfox/species.toml @@ -36,3 +36,10 @@ blush = ["body-basic", "ear-blush", "eyes-closed", "blush", "mouth-hmpf"] heart = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] egg = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding"] + +# Flags +heart_progress = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] +heart_enby = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] +heart_ace = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] +heart_demisexual = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] +heart_pan = ["body-basic", "eyes-basic", "left-hand", "right-hand", "holding", "big-object"] diff --git a/species/blobfox/variants/heart_ace.mustache b/species/blobfox/variants/heart_ace.mustache new file mode 100644 index 0000000..90e5eeb --- /dev/null +++ b/species/blobfox/variants/heart_ace.mustache @@ -0,0 +1,21 @@ +{{>header}} + {{>body}} + + {{>eyes}} + + + + {{#heart}}#heart{{/heart}} + + + + + + {{#flag_ace}}{{/flag_ace}} + + + + {{#set-fill}} rgba(255,255,255,0.5) | {{#heart}}#heart-reflection{{/heart}} {{/set-fill}} + + {{>hands}} +{{>footer}} diff --git a/species/blobfox/variants/heart_demisexual.mustache b/species/blobfox/variants/heart_demisexual.mustache new file mode 100644 index 0000000..c508c39 --- /dev/null +++ b/species/blobfox/variants/heart_demisexual.mustache @@ -0,0 +1,21 @@ +{{>header}} + {{>body}} + + {{>eyes}} + + + + {{#heart}}#heart{{/heart}} + + + + + + {{#flag_demisexual}}{{/flag_demisexual}} + + + + {{#set-fill}} rgba(255,255,255,0.5) | {{#heart}}#heart-reflection{{/heart}} {{/set-fill}} + + {{>hands}} +{{>footer}} diff --git a/species/blobfox/variants/heart_enby.mustache b/species/blobfox/variants/heart_enby.mustache new file mode 100644 index 0000000..71ccdff --- /dev/null +++ b/species/blobfox/variants/heart_enby.mustache @@ -0,0 +1,21 @@ +{{>header}} + {{>body}} + + {{>eyes}} + + + + {{#heart}}#heart{{/heart}} + + + + + + {{#flag_enby}}{{/flag_enby}} + + + + {{#set-fill}} rgba(255,255,255,0.5) | {{#heart}}#heart-reflection{{/heart}} {{/set-fill}} + + {{>hands}} +{{>footer}} diff --git a/species/blobfox/variants/heart_pan.mustache b/species/blobfox/variants/heart_pan.mustache new file mode 100644 index 0000000..ec04719 --- /dev/null +++ b/species/blobfox/variants/heart_pan.mustache @@ -0,0 +1,21 @@ +{{>header}} + {{>body}} + + {{>eyes}} + + + + {{#heart}}#heart{{/heart}} + + + + + + {{#flag_pan}}{{/flag_pan}} + + + + {{#set-fill}} rgba(255,255,255,0.5) | {{#heart}}#heart-reflection{{/heart}} {{/set-fill}} + + {{>hands}} +{{>footer}} diff --git a/species/blobfox/variants/heart_progress.mustache b/species/blobfox/variants/heart_progress.mustache new file mode 100644 index 0000000..d515e0f --- /dev/null +++ b/species/blobfox/variants/heart_progress.mustache @@ -0,0 +1,21 @@ +{{>header}} + {{>body}} + + {{>eyes}} + + + + {{#heart}}#heart{{/heart}} + + + + + + {{#flag_progress}}{{/flag_progress}} + + + + {{#set-fill}} rgba(255,255,255,0.5) | {{#heart}}#heart-reflection{{/heart}} {{/set-fill}} + + {{>hands}} +{{>footer}} diff --git a/species/blobstella/assets/flag_pan.svg b/species/blobstella/assets/flag_pan.svg new file mode 100644 index 0000000..ea27db9 --- /dev/null +++ b/species/blobstella/assets/flag_pan.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/species/blobstella/templates/body-basic.mustache b/species/blobstella/templates/body-basic.mustache index e767445..128eee0 100644 --- a/species/blobstella/templates/body-basic.mustache +++ b/species/blobstella/templates/body-basic.mustache @@ -16,8 +16,14 @@ {{! Marks }} - {{#base}}#left-marks{{/base}} - {{#base}}#right-marks{{/base}} + {{#set-fill}} + {{vars.marks_color}} + | {{#base}}#left-marks{{/base}} + {{/set-fill}} + {{#set-fill}} + {{vars.marks_color}} + | {{#base}}#right-marks{{/base}} + {{/set-fill}} {{! Whiskers }} diff --git a/src/bin/rescale.rs b/src/bin/rescale.rs index 5998237..d99b988 100644 --- a/src/bin/rescale.rs +++ b/src/bin/rescale.rs @@ -98,8 +98,13 @@ fn rescale(element: &mut Element, scale: f64) { if let Some(units) = element.attributes.get_mut("document-units") { *units = "px".to_string(); } - } else if element.name == "ellipse" || element.name == "radialGradient" || element.name == "linearGradient" { - const PROPS: [&'static str; 11] = [ + } else if + element.name == "ellipse" + || element.name == "radialGradient" + || element.name == "linearGradient" + || element.name == "rect" + { + const PROPS: [&'static str; 15] = [ "cx", "cy", "rx", @@ -110,7 +115,11 @@ fn rescale(element: &mut Element, scale: f64) { "x1", "x2", "y1", - "y2" + "y2", + "x", + "y", + "width", + "height", ]; for prop in PROPS { @@ -120,6 +129,21 @@ fn rescale(element: &mut Element, scale: f64) { } } } + } else if element.name == "polygon" { + if let Some(points) = element.attributes.get_mut("points") { + let new_points = points.split_whitespace().map(|pair| { + let parsed = pair.split(',').map(|x| x.parse::()).collect::>(); + if let [Ok(x), Ok(y)] = parsed[..] { + format!("{},{}", x * scale, y * scale) + } else if let [Ok(z)] = parsed[..] { + format!("{}", z * scale) + } else { + pair.to_string() + } + }).collect::>().join(" "); + + *points = new_points; + } } if let Some(style) = element.attributes.get_mut("style") { diff --git a/src/template.rs b/src/template.rs index 471efa9..293e10b 100644 --- a/src/template.rs +++ b/src/template.rs @@ -237,12 +237,21 @@ impl PartialLoader for RenderingContext { } fn set_fill(color: &str, xml: &mut Element) { - // Substitute the fill color - if let Some(style) = xml.attributes.get("style") { - xml.attributes.insert( - "style".to_string(), - format!("{};fill: {};", style, color), - ); + // Substitute the fill color; TODO: handle transparency for SVG 1.1 + if let Some(style) = xml.attributes.get_mut("style") { + let mut new_style = Vec::new(); + + for rule in style.split(';') { + if let [name, value] = rule.splitn(2, ':').collect::>()[..] { + if name.trim() != "fill" && name.trim() != "fill-opacity" { + new_style.push(format!("{}:{}", name, value)); + } + } + } + + new_style.push(format!("fill: {};", color)); + + *style = new_style.join(";"); } if let Some(_fill) = xml.attributes.get("fill") { xml.attributes.insert("fill".to_string(), color.to_string()); @@ -257,7 +266,10 @@ fn set_fill(color: &str, xml: &mut Element) { pub fn query_selector(svg: Element, pattern: &str) -> Option { if pattern == "" { - return Some(svg); + // NOTE: it looks like having a nested svg makes resvg unhappy + let mut group = Element::new("g"); + group.children = svg.children; + return Some(group); } for child in svg.children {