Implement {Add,Sub,Mul}Assign for RectF

This commit is contained in:
Corey Farwell 2020-05-08 21:25:45 -04:00
parent aa1279d692
commit e993e350e2
1 changed files with 43 additions and 1 deletions

View File

@ -12,7 +12,7 @@
use crate::vector::{IntoVector2F, Vector2F, Vector2I};
use pathfinder_simd::default::{F32x4, I32x4};
use std::ops::{Add, Mul, Sub};
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub struct RectF(pub F32x4);
@ -198,6 +198,13 @@ impl Add<Vector2F> for RectF {
}
}
impl AddAssign<Vector2F> for RectF {
#[inline]
fn add_assign(&mut self, other: Vector2F) {
*self = *self + other
}
}
impl Add<f32> for RectF {
type Output = RectF;
#[inline]
@ -206,6 +213,13 @@ impl Add<f32> for RectF {
}
}
impl AddAssign<f32> for RectF {
#[inline]
fn add_assign(&mut self, other: f32) {
*self = *self + other
}
}
impl Mul<Vector2F> for RectF {
type Output = RectF;
#[inline]
@ -214,6 +228,13 @@ impl Mul<Vector2F> for RectF {
}
}
impl MulAssign<Vector2F> for RectF {
#[inline]
fn mul_assign(&mut self, other: Vector2F) {
*self = *self * other
}
}
impl Mul<f32> for RectF {
type Output = RectF;
#[inline]
@ -222,6 +243,13 @@ impl Mul<f32> for RectF {
}
}
impl MulAssign<f32> for RectF {
#[inline]
fn mul_assign(&mut self, other: f32) {
*self = *self * other
}
}
impl Sub<Vector2F> for RectF {
type Output = RectF;
#[inline]
@ -230,6 +258,13 @@ impl Sub<Vector2F> for RectF {
}
}
impl SubAssign<Vector2F> for RectF {
#[inline]
fn sub_assign(&mut self, other: Vector2F) {
*self = *self - other
}
}
impl Sub<f32> for RectF {
type Output = RectF;
#[inline]
@ -238,6 +273,13 @@ impl Sub<f32> for RectF {
}
}
impl SubAssign<f32> for RectF {
#[inline]
fn sub_assign(&mut self, other: f32) {
*self = *self - other
}
}
/// NB: The origin is inclusive, while the lower right point is exclusive.
#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub struct RectI(pub I32x4);