mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-27 03:35:51 +01:00
svg-filters(codegen): add pretty and ugly printing
This commit is contained in:
parent
bf60bdd814
commit
d87033d320
1 changed files with 16 additions and 3 deletions
|
@ -43,10 +43,25 @@ impl SvgDocument {
|
|||
self.filters.get_mut(&id.to_string()).unwrap()
|
||||
}
|
||||
|
||||
pub fn generate_svg_pretty(&self) -> String {
|
||||
let mut result = Vec::new();
|
||||
let doc_writer = quick_xml::Writer::new_with_indent(&mut result, b' ', 2);
|
||||
|
||||
self.generate(doc_writer);
|
||||
|
||||
String::from_utf8_lossy(&result).to_string()
|
||||
}
|
||||
|
||||
pub fn generate_svg(&self) -> String {
|
||||
let mut result = Vec::new();
|
||||
let mut doc_writer = quick_xml::Writer::new_with_indent(&mut result, b' ', 2);
|
||||
let doc_writer = quick_xml::Writer::new(&mut result);
|
||||
|
||||
self.generate(doc_writer);
|
||||
|
||||
String::from_utf8_lossy(&result).to_string()
|
||||
}
|
||||
|
||||
fn generate(&self, mut doc_writer: quick_xml::Writer<&mut Vec<u8>>) {
|
||||
doc_writer
|
||||
.create_element("svg")
|
||||
.write_inner_content(|writer| {
|
||||
|
@ -55,8 +70,6 @@ impl SvgDocument {
|
|||
.try_fold(writer, Self::gen_filter)
|
||||
.map(|_| {})
|
||||
});
|
||||
|
||||
String::from_utf8_lossy(&result).to_string()
|
||||
}
|
||||
|
||||
fn gen_filter<'w, 'r>(
|
||||
|
|
Loading…
Reference in a new issue