1mod clipper2;
2pub(crate) use clipper2::*;
3
4mod clipper_offset;
5pub use clipper_offset::*;
6
7mod double;
8pub use double::*;
9
10mod int64;
11pub use int64::*;
12
13#[cfg(test)]
14mod tests;
15
16pub(crate) unsafe fn malloc(size: usize) -> *mut std::os::raw::c_void {
17 libc::malloc(size)
18}
19
20pub(crate) unsafe fn free(p: *mut std::os::raw::c_void) {
21 libc::free(p)
22}
23
24#[derive(Clone, Copy)]
25pub enum FillRule {
26 EvenOdd,
27 NonZero,
28 Positive,
29 Negative,
30}
31
32#[derive(Clone, Copy)]
33pub enum ClipType {
34 None,
35 Intersection,
36 Union,
37 Difference,
38 Xor,
39}
40
41#[derive(Clone, Copy)]
42pub enum JoinType {
43 SquaerJoin,
44 RoundJoin,
45 MiterJoin,
46}
47
48#[derive(Clone, Copy)]
49pub enum EndType {
50 PolygonEnd,
51 JoinedEnd,
52 SquaerEnd,
53 RoundEnd,
54}
55
56#[derive(Clone, Copy)]
57pub enum PointInPolygonResult {
58 On,
59 Inside,
60 Outside,
61}
62
63impl From<ClipType> for ClipperClipType {
64 fn from(value: ClipType) -> Self {
65 match value {
66 ClipType::None => ClipperClipType_NONE,
67 ClipType::Intersection => ClipperClipType_INTERSECTION,
68 ClipType::Union => ClipperClipType_UNION,
69 ClipType::Difference => ClipperClipType_DIFFERENCE,
70 ClipType::Xor => ClipperClipType_XOR,
71 }
72 }
73}
74
75impl From<FillRule> for ClipperFillRule {
76 fn from(value: FillRule) -> Self {
77 match value {
78 FillRule::EvenOdd => ClipperFillRule_EVEN_ODD,
79 FillRule::NonZero => ClipperFillRule_NON_ZERO,
80 FillRule::Positive => ClipperFillRule_POSITIVE,
81 FillRule::Negative => ClipperFillRule_NEGATIVE,
82 }
83 }
84}
85
86impl From<JoinType> for ClipperJoinType {
87 fn from(value: JoinType) -> Self {
88 match value {
89 JoinType::SquaerJoin => ClipperJoinType_SQUARE_JOIN,
90 JoinType::RoundJoin => ClipperJoinType_ROUND_JOIN,
91 JoinType::MiterJoin => ClipperJoinType_MITER_JOIN,
92 }
93 }
94}
95
96impl From<EndType> for ClipperEndType {
97 fn from(value: EndType) -> Self {
98 match value {
99 EndType::PolygonEnd => ClipperEndType_POLYGON_END,
100 EndType::JoinedEnd => ClipperEndType_JOINED_END,
101 EndType::SquaerEnd => ClipperEndType_SQUARE_END,
102 EndType::RoundEnd => ClipperEndType_ROUND_END,
103 }
104 }
105}
106
107#[allow(non_upper_case_globals)]
108impl Into<PointInPolygonResult> for ClipperPointInPolygonResult {
109 fn into(self) -> PointInPolygonResult {
110 match self {
111 ClipperPointInPolygonResult_IS_ON => PointInPolygonResult::On,
112 ClipperPointInPolygonResult_IS_INSIDE => PointInPolygonResult::Inside,
113 ClipperPointInPolygonResult_IS_OUTSIDE => PointInPolygonResult::Outside,
114 _ => panic!("Not Supported")
115 }
116 }
117}