fix: replace base64 images with nested svg to fix rasterization blurriness
This commit is contained in:
+18
-6
@@ -25,15 +25,27 @@ impl CompositeIcon {
|
||||
|
||||
pub fn render(&self) -> String {
|
||||
if let Some(emblem) = &self.emblem {
|
||||
use base64::prelude::*;
|
||||
let bg_b64 = BASE64_STANDARD.encode(&self.bg.content);
|
||||
let emblem_b64 = BASE64_STANDARD.encode(&emblem.content);
|
||||
fn strip_xml(svg: &str) -> &str {
|
||||
if let Some(idx) = svg.find("<svg") {
|
||||
&svg[idx..]
|
||||
} else {
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
let bg_svg = strip_xml(&self.bg.content);
|
||||
let emblem_svg = strip_xml(&emblem.content);
|
||||
|
||||
format!(
|
||||
r#"<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<image x="0" y="0" width="64" height="64" href="data:image/svg+xml;base64,{}" />
|
||||
<image x="{}" y="{}" width="{}" height="{}" href="data:image/svg+xml;base64,{}" />
|
||||
<svg x="0" y="0" width="64" height="64">
|
||||
{}
|
||||
</svg>
|
||||
<svg x="{}" y="{}" width="{}" height="{}">
|
||||
{}
|
||||
</svg>
|
||||
</svg>"#,
|
||||
bg_b64, self.emblem_x, self.emblem_y, self.emblem_size, self.emblem_size, emblem_b64
|
||||
bg_svg, self.emblem_x, self.emblem_y, self.emblem_size, self.emblem_size, emblem_svg
|
||||
)
|
||||
} else {
|
||||
self.bg.content.clone()
|
||||
|
||||
Reference in New Issue
Block a user