feat: add CompositeIcon struct for nesting SVGs
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
use crate::color_scheme::ColorScheme;
|
||||
|
||||
pub struct CompositeIcon {
|
||||
pub bg: ColorScheme,
|
||||
pub emblem: Option<ColorScheme>,
|
||||
pub emblem_x: f64,
|
||||
pub emblem_y: f64,
|
||||
pub emblem_size: f64,
|
||||
}
|
||||
|
||||
impl CompositeIcon {
|
||||
pub fn new(bg: ColorScheme) -> Self {
|
||||
Self {
|
||||
bg,
|
||||
emblem: None,
|
||||
emblem_x: 32.0,
|
||||
emblem_y: 32.0,
|
||||
emblem_size: 32.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_emblem(&mut self, emblem: ColorScheme) {
|
||||
self.emblem = Some(emblem);
|
||||
}
|
||||
|
||||
pub fn render(&self) -> String {
|
||||
if let Some(emblem) = &self.emblem {
|
||||
format!(
|
||||
r#"<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg x="0" y="0" width="64" height="64" overflow="visible">
|
||||
{}
|
||||
</svg>
|
||||
<svg x="{}" y="{}" width="{}" height="{}" overflow="visible">
|
||||
{}
|
||||
</svg>
|
||||
</svg>"#,
|
||||
self.bg.content, self.emblem_x, self.emblem_y, self.emblem_size, self.emblem_size, emblem.content
|
||||
)
|
||||
} else {
|
||||
self.bg.content.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
mod color_scheme;
|
||||
mod composite_icon;
|
||||
mod config;
|
||||
mod icon_index;
|
||||
mod ui;
|
||||
|
||||
Reference in New Issue
Block a user