rust/integral-geometry/src/lib.rs
branchui-scaling
changeset 15663 d92eeb468dad
parent 15384 1c6d5656157c
child 15751 a4558e2be08c
equal deleted inserted replaced
15283:c4fd2813b127 15663:d92eeb468dad
    43         std::cmp::max(self.x.abs(), self.y.abs())
    43         std::cmp::max(self.x.abs(), self.y.abs())
    44     }
    44     }
    45 
    45 
    46     #[inline]
    46     #[inline]
    47     pub fn integral_norm(self) -> u32 {
    47     pub fn integral_norm(self) -> u32 {
    48         let sqr = (self.x as u64).pow(2) + (self.y as u64).pow(2);
    48         let sqr = (self.x as u64).wrapping_pow(2) + (self.y as u64).wrapping_pow(2);
    49         integral_sqrt(sqr) as u32
    49         integral_sqrt(sqr) as u32
    50     }
    50     }
    51 
    51 
    52     #[inline]
    52     #[inline]
    53     pub const fn transform(self, matrix: &[i32; 4]) -> Self {
    53     pub const fn transform(self, matrix: &[i32; 4]) -> Self {
   168     }
   168     }
   169 
   169 
   170     #[inline]
   170     #[inline]
   171     pub fn contains(&self, other: Self) -> bool {
   171     pub fn contains(&self, other: Self) -> bool {
   172         self.width >= other.width && self.height >= other.height
   172         self.width >= other.width && self.height >= other.height
       
   173     }
       
   174 
       
   175     #[inline]
       
   176     pub fn join(&self, other: Self) -> Self {
       
   177         Self {
       
   178             width: max(self.width, other.width),
       
   179             height: max(self.height, other.height)
       
   180         }
   173     }
   181     }
   174 }
   182 }
   175 
   183 
   176 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
   184 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
   177 pub struct SizeMask {
   185 pub struct SizeMask {