1pub trait OtRound<U, T = Self> {
14 fn ot_round(self) -> U;
15}
16
17impl OtRound<i16> for f64 {
18 #[inline]
19 fn ot_round(self) -> i16 {
20 (self + 0.5).floor() as i16
21 }
22}
23
24impl OtRound<i16> for f32 {
25 #[inline]
26 fn ot_round(self) -> i16 {
27 (self + 0.5).floor() as i16
28 }
29}
30
31impl OtRound<u16> for f64 {
32 #[inline]
33 fn ot_round(self) -> u16 {
34 (self + 0.5).floor() as u16
35 }
36}
37
38impl OtRound<u16> for f32 {
39 #[inline]
40 fn ot_round(self) -> u16 {
41 (self + 0.5).floor() as u16
42 }
43}
44
45impl OtRound<f64> for f64 {
46 #[inline]
47 fn ot_round(self) -> f64 {
48 (self + 0.5).floor()
49 }
50}
51
52impl OtRound<f32> for f32 {
53 #[inline]
54 fn ot_round(self) -> f32 {
55 (self + 0.5).floor()
56 }
57}
58
59impl OtRound<(i16, i16)> for kurbo::Point {
60 #[inline]
61 fn ot_round(self) -> (i16, i16) {
62 (self.x.ot_round(), self.y.ot_round())
63 }
64}
65
66impl OtRound<kurbo::Vec2> for kurbo::Vec2 {
67 #[inline]
68 fn ot_round(self) -> kurbo::Vec2 {
69 kurbo::Vec2::new((self.x + 0.5).floor(), (self.y + 0.5).floor())
70 }
71}