glifparser/glif/mfek/inner/
quad.rs1use crate::glif::contour::MFEKContourCommon;
2use crate::glif::point::MFEKPointCommon;
3use crate::glif::point::quad::QPoint;
4use crate::glif::inner::State;
5use crate::PointData;
6use crate::point::PointType;
7
8use super::MFEKContourInnerType;
9use super::cubic::MFEKCubicInner;
10use super::hyper::MFEKHyperInner;
11
12pub type MFEKQuadInner<PD> = Vec<QPoint<PD>>;
13
14impl<PD: PointData> State for MFEKQuadInner<PD> {
15 fn is_open(&self) -> bool {
16 return self[0].ptype == PointType::Move
17 }
18}
19
20impl<PD: PointData> MFEKContourCommon<PD> for MFEKQuadInner<PD> {
21 fn len(&self) -> usize {
22 self.len()
23 }
24
25 fn get_type(&self) -> MFEKContourInnerType {
26 MFEKContourInnerType::Quad
27 }
28
29 fn is_open(&self) -> bool {
30 State::is_open(self)
31 }
32
33 fn is_closed(&self) -> bool {
34 State::is_closed(self)
35 }
36
37 fn set_open(&mut self) {
38 self[0].ptype = PointType::Move
39 }
40
41 fn set_closed(&mut self) {
42 self[0].ptype = PointType::Curve
43 }
44
45 fn is_empty(&self) -> bool {
46 self.is_empty()
47 }
48
49 fn get_point(&self, pidx: usize) -> Option<&dyn MFEKPointCommon<PD>> {
50 if let Some(hp) = self.get(pidx) {
51 Some(hp)
52 } else {
53 None
54 }
55 }
56
57 fn get_point_mut(&mut self, pidx: usize) -> Option<&mut dyn MFEKPointCommon<PD>> {
58 if let Some(hp) = self.get_mut(pidx) {
59 Some(hp)
60 } else {
61 None
62 }
63 }
64
65 fn delete(&mut self, index: usize) {
66 self.remove(index);
67 }
68
69 fn reverse_points(&mut self) {
70 self.reverse();
71 }
72
73 fn quad(&self) -> Option<&MFEKQuadInner<PD>> {
74 Some(self)
75 }
76
77 fn quad_mut(&mut self) -> Option<&mut MFEKQuadInner<PD>> {
78 Some(self)
79 }
80
81 fn cubic(&self) -> Option<&MFEKCubicInner<PD>> {
82 None
83 }
84
85 fn cubic_mut(&mut self) -> Option<&mut MFEKCubicInner<PD>> {
86 None
87 }
88
89 fn hyper(&self) -> Option<&MFEKHyperInner<PD>> {
90 None
91 }
92
93 fn hyper_mut(&mut self) -> Option<&mut MFEKHyperInner<PD>> {
94 None
95 }
96}