skia_safe/modules/svg/fe/
lighting.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use super::{DebugAttributes, NodeSubtype};
use crate::{impl_default_make, prelude::*, scalar};
use skia_bindings as sb;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct KernelUnitLength {
    pub dx: scalar,
    pub dy: scalar,
}

impl KernelUnitLength {
    pub fn new(dx: scalar, dy: scalar) -> Self {
        Self { dx, dy }
    }

    pub fn new_all(value: scalar) -> Self {
        Self {
            dx: value,
            dy: value,
        }
    }
}

native_transmutable!(
    sb::SkSVGFeLighting_KernelUnitLength,
    KernelUnitLength,
    svg_kernel_unit_length_layout
);

pub type Lighting = RCHandle<sb::SkSVGFeLighting>;

impl NodeSubtype for sb::SkSVGFeLighting {
    type Base = sb::SkSVGFe;
}

impl DebugAttributes for Lighting {
    const NAME: &'static str = "FeLighting";

    fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
        self.as_base()._dbg(
            builder
                .field("surface_scale", &self.surface_scale())
                .field("kernel_unit_length", &self.kernel_unit_length()),
        );
    }
}

impl Lighting {
    skia_svg_macros::attrs! {
        SkSVGFeLighting => {
            *surface_scale: scalar [get(value) => value, set(value) => value],
            *kernel_unit_length?: KernelUnitLength [get(value) => value.map(KernelUnitLength::from_native_c), set(value) => value.into_native()]
        }
    }
}

pub type Specular = RCHandle<sb::SkSVGFeSpecularLighting>;

impl NodeSubtype for sb::SkSVGFeSpecularLighting {
    type Base = sb::SkSVGFeLighting;
}

impl_default_make!(Specular, sb::C_SkSVGFeSpecularLighting_Make);

impl DebugAttributes for Specular {
    const NAME: &'static str = "FeSpecularLighting";

    fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
        self.as_base()._dbg(
            builder
                .field("specular_constant", &self.specular_constant())
                .field("specular_exponent", &self.specular_exponent()),
        );
    }
}

impl Specular {
    skia_svg_macros::attrs! {
        SkSVGFeSpecularLighting => {
            *specular_constant: scalar [get(value) => value, set(value) => value],
            *specular_exponent: scalar [get(value) => value, set(value) => value]
        }
    }
}

pub type Diffuse = RCHandle<sb::SkSVGFeDiffuseLighting>;

impl NodeSubtype for sb::SkSVGFeDiffuseLighting {
    type Base = sb::SkSVGFeLighting;
}

impl_default_make!(Diffuse, sb::C_SkSVGFeDiffuseLighting_Make);

impl DebugAttributes for Diffuse {
    const NAME: &'static str = "FeDiffuseLighting";

    fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
        self.as_base()
            ._dbg(builder.field("diffuse_constant", &self.diffuse_constant()));
    }
}

impl Diffuse {
    skia_svg_macros::attrs! {
        SkSVGFeDiffuseLighting => {
            *diffuse_constant: scalar [get(value) => value, set(value) => value]
        }
    }
}