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
pub mod merge_path_effect {
    use crate::{prelude::*, PathEffect, PathOp};
    use skia_bindings as sb;

    impl PathEffect {
        pub fn merge(
            one: impl Into<PathEffect>,
            two: impl Into<PathEffect>,
            op: PathOp,
        ) -> PathEffect {
            new(one, two, op)
        }
    }

    pub fn new(one: impl Into<PathEffect>, two: impl Into<PathEffect>, op: PathOp) -> PathEffect {
        PathEffect::from_ptr(unsafe {
            sb::C_SkMergePathEffect_Make(one.into().into_ptr(), two.into().into_ptr(), op)
        })
        .unwrap()
    }
}

pub mod matrix_path_effect {
    use crate::{prelude::*, Matrix, PathEffect, Vector};
    use skia_bindings as sb;

    impl PathEffect {
        pub fn matrix_translate(d: impl Into<Vector>) -> Option<PathEffect> {
            new_translate(d)
        }

        pub fn matrix(matrix: &Matrix) -> Option<PathEffect> {
            new(matrix)
        }
    }

    pub fn new_translate(d: impl Into<Vector>) -> Option<PathEffect> {
        let d = d.into();
        PathEffect::from_ptr(unsafe { sb::C_SkMatrixPathEffect_MakeTranslate(d.x, d.y) })
    }

    pub fn new(matrix: &Matrix) -> Option<PathEffect> {
        PathEffect::from_ptr(unsafe { sb::C_SkMatrixPathEffect_Make(matrix.native()) })
    }
}

pub mod stroke_path_effect {
    use crate::{paint, scalar, PathEffect};
    use skia_bindings as sb;

    impl PathEffect {
        pub fn stroke(
            width: scalar,
            join: paint::Join,
            cap: paint::Cap,
            miter: impl Into<Option<scalar>>,
        ) -> Option<PathEffect> {
            new(width, join, cap, miter)
        }
    }

    pub fn new(
        width: scalar,
        join: paint::Join,
        cap: paint::Cap,
        miter: impl Into<Option<scalar>>,
    ) -> Option<PathEffect> {
        PathEffect::from_ptr(unsafe {
            sb::C_SkStrokePathEffect_Make(width, join, cap, miter.into().unwrap_or(4.0))
        })
    }
}