Merge pull request #331 from frewsxcv/frewsxcv-rect
Implement {Add,Sub,Mul}Assign for RectF
This commit is contained in:
commit
5ed26819bb
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
use crate::vector::{IntoVector2F, Vector2F, Vector2I};
|
use crate::vector::{IntoVector2F, Vector2F, Vector2I};
|
||||||
use pathfinder_simd::default::{F32x4, I32x4};
|
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)]
|
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||||
pub struct RectF(pub F32x4);
|
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 {
|
impl Add<f32> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[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 {
|
impl Mul<Vector2F> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[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 {
|
impl Mul<f32> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[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 {
|
impl Sub<Vector2F> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[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 {
|
impl Sub<f32> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[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.
|
/// NB: The origin is inclusive, while the lower right point is exclusive.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||||
pub struct RectI(pub I32x4);
|
pub struct RectI(pub I32x4);
|
||||||
|
|
Loading…
Reference in New Issue