forked from katzen-cafe/iowo
svg-filters: blend node
This commit is contained in:
parent
f59062cf88
commit
e17fffb66b
6 changed files with 46 additions and 11 deletions
20
crates/svg-filters/src/tests/blend.rs
Normal file
20
crates/svg-filters/src/tests/blend.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use crate::{
|
||||
codegen::SvgDocument,
|
||||
types::nodes::{primitives::blend::BlendMode, standard_input::StandardInput},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_offset_blend() {
|
||||
let mut doc = SvgDocument::new();
|
||||
|
||||
let blend = doc.create_filter("blend");
|
||||
|
||||
let offset0 = blend.offset(StandardInput::SourceGraphic, 100., 0.);
|
||||
let offset1 = blend.offset(StandardInput::SourceGraphic, -100., 0.);
|
||||
blend.blend(offset0, offset1, BlendMode::Multiply);
|
||||
|
||||
assert_eq!(
|
||||
doc.generate_svg(),
|
||||
r#"<svg><filter id="blend"><feOffset dx="-100" dy="0" in="SourceGraphic" result="r7"/><feOffset dx="100" dy="0" in="SourceGraphic" result="r6"/><feBlend mode="multiply" in="r6" in2="r7"/></filter></svg>"#
|
||||
);
|
||||
}
|
|
@ -9,5 +9,5 @@ fn test_simple_blur() {
|
|||
assert_eq!(
|
||||
doc.generate_svg(),
|
||||
r#"<svg><filter id="blur"><feGaussianBlur stdDeviation="30 30" in="SourceGraphic"/></filter></svg>"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ use crate::{codegen::SvgDocument, types::nodes::standard_input::StandardInput};
|
|||
#[test]
|
||||
fn test_offset_simple() {
|
||||
let mut doc = SvgDocument::new();
|
||||
let mut offset = doc.create_filter("offset");
|
||||
let offset = doc.create_filter("offset");
|
||||
|
||||
offset.offset(StandardInput::SourceGraphic, 25., -25.);
|
||||
|
||||
assert_eq!(
|
||||
doc.generate_svg(),
|
||||
r#"<svg><filter id="offset"><feOffset dx="25" dy="-25" in="SourceGraphic"/></filter></svg>"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue