skia_safe/modules/svg/
filter.rs

1use super::{BoundingBoxUnits, DebugAttributes, Length, NodeSubtype};
2use crate::{impl_default_make, prelude::*};
3use skia_bindings as sb;
4
5pub type Filter = RCHandle<sb::SkSVGFilter>;
6
7impl DebugAttributes for Filter {
8    const NAME: &'static str = "Filter";
9
10    fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
11        self.as_base()._dbg(
12            builder
13                .field("x", &self.x())
14                .field("y", &self.y())
15                .field("width", &self.width())
16                .field("height", &self.height())
17                .field("filter_units", self.filter_units())
18                .field("primitive_units", self.primitive_units()),
19        );
20    }
21}
22
23impl NodeSubtype for sb::SkSVGFilter {
24    type Base = sb::SkSVGContainer;
25}
26
27impl_default_make!(Filter, sb::C_SkSVGFilter_Make);
28
29impl Filter {
30    // TODO: wrap applyProperties()
31    // TODO: wrap buildFilterDAG
32
33    skia_svg_macros::attrs! {
34        SkSVGFilter => {
35            x: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
36            y: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
37            width: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
38            height: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
39            filter_units: BoundingBoxUnits [get(value) => &value.fType, set(value) => sb::SkSVGObjectBoundingBoxUnits { fType: value }],
40            primitive_units: BoundingBoxUnits [get(value) => &value.fType, set(value) => sb::SkSVGObjectBoundingBoxUnits { fType: value }]
41        }
42    }
43}