Add some more operators to rects and vectors
This commit is contained in:
parent
542d2c27fa
commit
404d536254
|
@ -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};
|
use std::ops::{Add, Mul, Sub};
|
||||||
|
|
||||||
#[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,14 @@ impl Add<Vector2F> for RectF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Add<f32> for RectF {
|
||||||
|
type Output = RectF;
|
||||||
|
#[inline]
|
||||||
|
fn add(self, other: f32) -> RectF {
|
||||||
|
RectF::new(self.origin() + other, self.size())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Mul<Vector2F> for RectF {
|
impl Mul<Vector2F> for RectF {
|
||||||
type Output = RectF;
|
type Output = RectF;
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -214,6 +222,22 @@ impl Mul<f32> for RectF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sub<Vector2F> for RectF {
|
||||||
|
type Output = RectF;
|
||||||
|
#[inline]
|
||||||
|
fn sub(self, other: Vector2F) -> RectF {
|
||||||
|
RectF::new(self.origin() - other, self.size())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sub<f32> for RectF {
|
||||||
|
type Output = RectF;
|
||||||
|
#[inline]
|
||||||
|
fn sub(self, other: f32) -> RectF {
|
||||||
|
RectF::new(self.origin() - other, self.size())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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);
|
||||||
|
|
|
@ -200,6 +200,14 @@ impl Sub<Vector2F> for Vector2F {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sub<f32> for Vector2F {
|
||||||
|
type Output = Vector2F;
|
||||||
|
#[inline]
|
||||||
|
fn sub(self, other: f32) -> Vector2F {
|
||||||
|
self - Vector2F::splat(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Mul<Vector2F> for Vector2F {
|
impl Mul<Vector2F> for Vector2F {
|
||||||
type Output = Vector2F;
|
type Output = Vector2F;
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue