Merge pull request #2767 from airstrike/impl-division
Implement division operation for `Rectangle`, `Size` and `Vector`
This commit is contained in:
commit
281e58da8e
3 changed files with 25 additions and 16 deletions
|
|
@ -394,19 +394,3 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> std::ops::Mul<Vector<T>> for Rectangle<T>
|
|
||||||
where
|
|
||||||
T: std::ops::Mul<Output = T> + Copy,
|
|
||||||
{
|
|
||||||
type Output = Rectangle<T>;
|
|
||||||
|
|
||||||
fn mul(self, scale: Vector<T>) -> Self {
|
|
||||||
Rectangle {
|
|
||||||
x: self.x * scale.x,
|
|
||||||
y: self.y * scale.y,
|
|
||||||
width: self.width * scale.x,
|
|
||||||
height: self.height * scale.y,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::ops::Div<T> for Size<T>
|
||||||
|
where
|
||||||
|
T: std::ops::Div<Output = T> + Copy,
|
||||||
|
{
|
||||||
|
type Output = Size<T>;
|
||||||
|
|
||||||
|
fn div(self, rhs: T) -> Self::Output {
|
||||||
|
Size {
|
||||||
|
width: self.width / rhs,
|
||||||
|
height: self.height / rhs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> std::ops::Mul<Vector<T>> for Size<T>
|
impl<T> std::ops::Mul<Vector<T>> for Size<T>
|
||||||
where
|
where
|
||||||
T: std::ops::Mul<Output = T> + Copy,
|
T: std::ops::Mul<Output = T> + Copy,
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::ops::Div<T> for Vector<T>
|
||||||
|
where
|
||||||
|
T: std::ops::Div<Output = T> + Copy,
|
||||||
|
{
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn div(self, scale: T) -> Self {
|
||||||
|
Self::new(self.x / scale, self.y / scale)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Default for Vector<T>
|
impl<T> Default for Vector<T>
|
||||||
where
|
where
|
||||||
T: Default,
|
T: Default,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue