skia_safe/modules/svg/fe/
color_matrix.rs

1use super::{DebugAttributes, NodeSubtype};
2use crate::{impl_default_make, prelude::*, scalar};
3use skia_bindings as sb;
4
5pub type ColorMatrixKind = sb::SkSVGFeColorMatrixType;
6variant_name!(ColorMatrixKind::Matrix);
7
8pub type ColorMatrix = RCHandle<sb::SkSVGFeColorMatrix>;
9
10impl NodeSubtype for sb::SkSVGFeColorMatrix {
11    type Base = sb::SkSVGFe;
12}
13
14impl_default_make!(ColorMatrix, sb::C_SkSVGFeColorMatrix_Make);
15
16impl DebugAttributes for ColorMatrix {
17    const NAME: &'static str = "FeColorMatrix";
18
19    fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
20        self.as_base()._dbg(
21            builder
22                .field("values", &self.values())
23                .field("kind", self.kind()),
24        );
25    }
26}
27
28impl ColorMatrix {
29    skia_svg_macros::attrs! {
30        SkSVGFeColorMatrix => {
31            "type" as kind: ColorMatrixKind [get(value) => value, set(value) => value]
32        }
33    }
34
35    pub fn values(&self) -> &[scalar] {
36        unsafe {
37            safer::from_raw_parts(
38                sb::C_SkSVGFeColorMatrix_getValues(self.native()),
39                sb::C_SkSVGFeColorMatrix_getValuesCount(self.native()),
40            )
41        }
42    }
43}