1use crate::path::Path;
4use crate::path_op::PathOp;
5use crate::pathkit;
6use crate::rect::Rect;
7
8pub fn path_op(path1: &Path, path2: &Path, op: PathOp) -> Option<Path> {
11 let mut result = Path::new();
12 let ok = unsafe {
13 pathkit::Op(
14 path1.as_raw() as *const _,
15 path2.as_raw() as *const _,
16 op.into(),
17 result.as_raw_mut() as *mut _,
18 )
19 };
20 if ok {
21 Some(result)
22 } else {
23 None
24 }
25}
26
27pub fn simplify(path: &Path) -> Option<Path> {
30 let mut result = Path::new();
31 let ok = unsafe {
32 pathkit::Simplify(path.as_raw() as *const _, result.as_raw_mut() as *mut _)
33 };
34 if ok {
35 Some(result)
36 } else {
37 None
38 }
39}
40
41pub fn pathops_tight_bounds(path: &Path) -> Option<Rect> {
46 let mut result = pathkit::SkRect {
47 fLeft: 0.0,
48 fTop: 0.0,
49 fRight: 0.0,
50 fBottom: 0.0,
51 };
52 let ok = unsafe { pathkit::TightBounds(path.as_raw() as *const _, &mut result as *mut _) };
53 if ok {
54 Some(result.into())
55 } else {
56 None
57 }
58}