forked from katzen-cafe/iowo
svg-filters: init
This commit is contained in:
parent
98850ee1e9
commit
69f0baf425
25 changed files with 445 additions and 1 deletions
25
crates/svg-filters/src/types/nodes/primitives/blend.rs
Normal file
25
crates/svg-filters/src/types/nodes/primitives/blend.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
/// [feBlend](https://www.w3.org/TR/SVG11/filters.html#feBlendElement)
|
||||
pub struct Blend {
|
||||
mode: BlendMode,
|
||||
}
|
||||
|
||||
/// as according to https://drafts.fxtf.org/compositing-1/#blending
|
||||
enum BlendMode {
|
||||
Normal,
|
||||
Multiply,
|
||||
Screen,
|
||||
Overlay,
|
||||
Darken,
|
||||
Lighten,
|
||||
ColorDodge,
|
||||
ColorBurn,
|
||||
HardLight,
|
||||
SoftLight,
|
||||
Difference,
|
||||
Exclusion,
|
||||
|
||||
Hue,
|
||||
Saturation,
|
||||
Color,
|
||||
Luminosity,
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/// [feColorMatrix](https://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement)
|
||||
pub struct ColorMatrix {
|
||||
cm_type: ColorMatrixType,
|
||||
}
|
||||
|
||||
enum ColorMatrixType {
|
||||
Matrix {
|
||||
values: [f32; 20],
|
||||
},
|
||||
Saturate {
|
||||
// is the values attribute anyway tho
|
||||
value: f32,
|
||||
},
|
||||
HueRotate {
|
||||
// also the values attribute
|
||||
degrees: f32,
|
||||
},
|
||||
LuminanceToAlpha,
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/// [feComponentTransfer](https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement)
|
||||
pub struct ComponentTransfer {
|
||||
func_r: TransferFunction,
|
||||
func_g: TransferFunction,
|
||||
func_b: TransferFunction,
|
||||
func_a: TransferFunction,
|
||||
}
|
||||
|
||||
/// [transfer functions](https://www.w3.org/TR/SVG11/filters.html#transferFuncElements)
|
||||
enum TransferFunction {
|
||||
Identity,
|
||||
Table {
|
||||
table_values: Vec<f32>,
|
||||
},
|
||||
Discrete {
|
||||
table_values: Vec<f32>,
|
||||
},
|
||||
Linear {
|
||||
slope: f32,
|
||||
intercept: f32,
|
||||
},
|
||||
Gamma {
|
||||
amplitude: f32,
|
||||
exponent: f32,
|
||||
offset: f32,
|
||||
},
|
||||
}
|
13
crates/svg-filters/src/types/nodes/primitives/composite.rs
Normal file
13
crates/svg-filters/src/types/nodes/primitives/composite.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
/// [feComposite](https://www.w3.org/TR/SVG11/filters.html#feCompositeElement)
|
||||
pub struct Composite {
|
||||
operator: CompositeOperator,
|
||||
}
|
||||
|
||||
enum CompositeOperator {
|
||||
Over,
|
||||
In,
|
||||
Out,
|
||||
Atop,
|
||||
Xor,
|
||||
Arithmetic { k1: f32, k2: f32, k3: f32, k4: f32 },
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
pub struct ConvolveMatrix {
|
||||
order: (u16, u16),
|
||||
// must be checked to be `order.0 * order.1`
|
||||
kernel_matrix: Vec<f32>,
|
||||
divisor: f32,
|
||||
bias: f32,
|
||||
target_x: i32,
|
||||
target_y: i32,
|
||||
edge_mode: EdgeMode,
|
||||
kernel_unit_length: (f32, f32),
|
||||
preserve_alpha: bool,
|
||||
}
|
||||
|
||||
enum EdgeMode {
|
||||
None,
|
||||
Duplicate,
|
||||
Wrap,
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
// TODO
|
||||
pub struct DiffuseLighting;
|
|
@ -0,0 +1,13 @@
|
|||
/// [feDisplacementMap](https://www.w3.org/TR/SVG11/filters.html#feDisplacementMapElement)
|
||||
pub struct DisplacementMap {
|
||||
scale: f32,
|
||||
x_channel_selector: Channel,
|
||||
y_channel_selector: Channel,
|
||||
}
|
||||
|
||||
enum Channel {
|
||||
A,
|
||||
R,
|
||||
G,
|
||||
B,
|
||||
}
|
7
crates/svg-filters/src/types/nodes/primitives/flood.rs
Normal file
7
crates/svg-filters/src/types/nodes/primitives/flood.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use csscolorparser::Color;
|
||||
|
||||
/// [feFlood](https://www.w3.org/TR/SVG11/filters.html#feFloodElement)
|
||||
pub struct Flood {
|
||||
flood_color: Color,
|
||||
flood_opacity: f32,
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/// [feGaussianBlur](https://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement)
|
||||
pub struct GaussianBlur {
|
||||
std_deviation: (f32, f32),
|
||||
}
|
2
crates/svg-filters/src/types/nodes/primitives/image.rs
Normal file
2
crates/svg-filters/src/types/nodes/primitives/image.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
// TODO
|
||||
pub struct Image;
|
2
crates/svg-filters/src/types/nodes/primitives/merge.rs
Normal file
2
crates/svg-filters/src/types/nodes/primitives/merge.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
// TODO
|
||||
pub struct Merge;
|
10
crates/svg-filters/src/types/nodes/primitives/morphology.rs
Normal file
10
crates/svg-filters/src/types/nodes/primitives/morphology.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
/// [feMorphology](https://www.w3.org/TR/SVG11/filters.html#feMorphologyElement)
|
||||
pub struct Morphology {
|
||||
operator: Operator,
|
||||
radius: (f32, f32),
|
||||
}
|
||||
|
||||
enum Operator {
|
||||
Erode,
|
||||
Dilate,
|
||||
}
|
5
crates/svg-filters/src/types/nodes/primitives/offset.rs
Normal file
5
crates/svg-filters/src/types/nodes/primitives/offset.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
/// [feOffset](https://www.w3.org/TR/SVG11/filters.html#feOffsetElement)
|
||||
pub struct Offset {
|
||||
dx: f32,
|
||||
dy: f32,
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
// TODO
|
||||
pub struct SpecularLighting;
|
2
crates/svg-filters/src/types/nodes/primitives/tile.rs
Normal file
2
crates/svg-filters/src/types/nodes/primitives/tile.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
/// [feTile](https://www.w3.org/TR/SVG11/filters.html#feTileElement)
|
||||
pub struct Tile;
|
18
crates/svg-filters/src/types/nodes/primitives/turbulence.rs
Normal file
18
crates/svg-filters/src/types/nodes/primitives/turbulence.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
/// [feTurbulence](https://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement)
|
||||
pub struct Turbulence {
|
||||
base_frequency: (f32, f32),
|
||||
num_octaves: (u16),
|
||||
seed: u32,
|
||||
stich_tiles: StitchTiles,
|
||||
// attr name: type
|
||||
noise_type: NoiseType,
|
||||
}
|
||||
|
||||
enum StitchTiles {
|
||||
Stitch,
|
||||
NoStitch,
|
||||
}
|
||||
enum NoiseType {
|
||||
Turbulence,
|
||||
FractalNoise,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue