forked from katzen-cafe/iowo
svg-filters(primitives): start with feComponentTransfer
This commit is contained in:
parent
77bcb54b5e
commit
384fef5a81
2 changed files with 21 additions and 8 deletions
|
@ -6,6 +6,7 @@ use self::{
|
||||||
primitives::{
|
primitives::{
|
||||||
blend::{Blend, BlendMode},
|
blend::{Blend, BlendMode},
|
||||||
color_matrix::{ColorMatrix, ColorMatrixType},
|
color_matrix::{ColorMatrix, ColorMatrixType},
|
||||||
|
component_transfer::{ComponentTransfer, TransferFn},
|
||||||
composite::{Composite, CompositeOperator},
|
composite::{Composite, CompositeOperator},
|
||||||
gaussian_blur::GaussianBlur,
|
gaussian_blur::GaussianBlur,
|
||||||
offset::Offset,
|
offset::Offset,
|
||||||
|
@ -145,9 +146,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn composite_arithmetic(k1: f32, k2: f32, k3: f32, k4: f32) -> Self {
|
pub fn composite_arithmetic(k1: f32, k2: f32, k3: f32, k4: f32) -> Self {
|
||||||
Self::simple(FePrimitive::Composite(Composite::arithmetic(
|
Self::composite(CompositeOperator::Arithmetic { k1, k2, k3, k4 })
|
||||||
k1, k2, k3, k4,
|
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gaussian_blur(v: u16) -> Self {
|
pub fn gaussian_blur(v: u16) -> Self {
|
||||||
|
@ -161,4 +160,18 @@ impl Node {
|
||||||
pub fn offset(dx: f32, dy: f32) -> Self {
|
pub fn offset(dx: f32, dy: f32) -> Self {
|
||||||
Self::simple(FePrimitive::Offset(Offset::new(dx, dy)))
|
Self::simple(FePrimitive::Offset(Offset::new(dx, dy)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn component_transfer_rgba(
|
||||||
|
r: TransferFn,
|
||||||
|
g: TransferFn,
|
||||||
|
b: TransferFn,
|
||||||
|
a: TransferFn,
|
||||||
|
) -> Self {
|
||||||
|
Self::simple(FePrimitive::ComponentTransfer(ComponentTransfer {
|
||||||
|
func_r: r,
|
||||||
|
func_g: g,
|
||||||
|
func_b: b,
|
||||||
|
func_a: a,
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/// [feComponentTransfer](https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement)
|
/// [feComponentTransfer](https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement)
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ComponentTransfer {
|
pub struct ComponentTransfer {
|
||||||
func_r: TransferFunction,
|
pub func_r: TransferFn,
|
||||||
func_g: TransferFunction,
|
pub func_g: TransferFn,
|
||||||
func_b: TransferFunction,
|
pub func_b: TransferFn,
|
||||||
func_a: TransferFunction,
|
pub func_a: TransferFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [transfer functions](https://www.w3.org/TR/SVG11/filters.html#transferFuncElements)
|
/// [transfer functions](https://www.w3.org/TR/SVG11/filters.html#transferFuncElements)
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum TransferFunction {
|
pub enum TransferFn {
|
||||||
Identity,
|
Identity,
|
||||||
Table {
|
Table {
|
||||||
table_values: Vec<f32>,
|
table_values: Vec<f32>,
|
||||||
|
|
Loading…
Reference in a new issue