forked from katzen-cafe/iowo
svg-filters: get bare basic xml generation going
This commit is contained in:
parent
56848a1b05
commit
01b1880089
6 changed files with 227 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
/// [feBlend](https://www.w3.org/TR/SVG11/filters.html#feBlendElement)
|
||||
#[derive(Debug)]
|
||||
pub(in crate::types::nodes) struct Blend {
|
||||
pub struct Blend {
|
||||
mode: BlendMode,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use quick_xml::{events::attributes::Attribute, name::QName, se::to_string};
|
||||
|
||||
use super::WriteElement;
|
||||
|
||||
/// [feColorMatrix](https://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement)
|
||||
#[derive(Debug)]
|
||||
pub struct ColorMatrix {
|
||||
|
@ -10,6 +16,34 @@ impl ColorMatrix {
|
|||
}
|
||||
}
|
||||
|
||||
impl WriteElement for ColorMatrix {
|
||||
fn attrs(&self) -> Vec<quick_xml::events::attributes::Attribute> {
|
||||
match &self.cm_type {
|
||||
ColorMatrixType::Matrix(v) => vec![Attribute {
|
||||
key: QName(b"values"),
|
||||
value: Cow::from(
|
||||
v.iter()
|
||||
.map(|v| v.to_string())
|
||||
.reduce(|mut acc, e| {
|
||||
acc.push(' ');
|
||||
acc.push_str(&e);
|
||||
acc
|
||||
})
|
||||
.expect("Should be able to concatenate the thingies")
|
||||
.into_bytes(),
|
||||
),
|
||||
}],
|
||||
ColorMatrixType::Saturate(v) => todo!(),
|
||||
ColorMatrixType::HueRotate(v) => todo!(),
|
||||
ColorMatrixType::LuminanceToAlpha => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn tag_name(&self) -> &'static str {
|
||||
"feColorMatrix"
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ColorMatrixType {
|
||||
Matrix(Box<[f32; 20]>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue