svg-filters: cleanup

This commit is contained in:
Schrottkatze 2024-03-17 00:51:20 +01:00
parent 384fef5a81
commit f59062cf88
No known key found for this signature in database
2 changed files with 1 additions and 45 deletions

View file

@ -10,51 +10,8 @@ use svg_filters::{
}; };
fn main() { fn main() {
// <filter id="chromabb" >
// <feColorMatrix values="1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0" in="SourceGraphic" />
// <feOffset dx="25" dy="0" />
// <feGaussianBlur stdDeviation="5 0" result="red" />
// <feColorMatrix values="0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0" result="grn" in="SourceGraphic" />
// <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0" in="SourceGraphic" />
// <feOffset dx="-25" dy="0" />
// <feGaussianBlur stdDeviation="5 0" result="blu"/>
// <feComposite in="red" in2="blu" operator="arithmetic" k2="1" k3="1" result="rb" />
// <feComposite in="rb" in2="grn" operator="arithmetic" k2="1" k3="1" />
// </filter>
let mut doc = SvgDocument::new(); let mut doc = SvgDocument::new();
let chromabb = doc.create_filter("chromabb_gen");
let chan_r = chromabb.color_matrix(
StandardInput::SourceGraphic,
ColorMatrixType::Matrix(Box::new([
1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
])),
);
let offset_r = chromabb.offset(chan_r, 25., 0.);
let blur_r = chromabb.gaussian_blur_xy(offset_r, 5, 0);
let chan_b = chromabb.color_matrix(
StandardInput::SourceGraphic,
ColorMatrixType::Matrix(Box::new([
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0.,
])),
);
let offset_b = chromabb.offset(chan_b, -25., 0.);
let blur_b = chromabb.gaussian_blur_xy(offset_b, 5, 0);
let composite_rb = chromabb.composite_arithmetic(blur_r, blur_b, 0., 1., 1., 0.);
let chan_g = chromabb.color_matrix(
StandardInput::SourceGraphic,
ColorMatrixType::Matrix(Box::new([
0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
])),
);
chromabb.composite_arithmetic(composite_rb, chan_g, 0., 1., 1., 0.);
eprintln!("{}", doc.generate_svg_pretty());
println!("{}", doc.generate_svg()); println!("{}", doc.generate_svg());
} }

View file

@ -61,7 +61,6 @@ pub trait WriteElement {
/// svg filter effects primitives /// svg filter effects primitives
#[derive(Debug)] #[derive(Debug)]
pub enum FePrimitive { pub enum FePrimitive {
// 2 inputs
Blend(blend::Blend), Blend(blend::Blend),
ColorMatrix(color_matrix::ColorMatrix), ColorMatrix(color_matrix::ColorMatrix),
ComponentTransfer(component_transfer::ComponentTransfer), ComponentTransfer(component_transfer::ComponentTransfer),