pub struct Quad<T = i32, const N: usize = 2>(/* private fields */);
Expand description
A Quad
or quadrilateral, a four-sided polygon.
Quad
is similar to Rect but the angles between edges are not constrained to 90 degrees.
Please see the module-level documentation for examples.
Implementations§
Source§impl<T, const N: usize> Quad<T, N>
impl<T, const N: usize> Quad<T, N>
Sourcepub fn new<P1, P2, P3, P4>(p1: P1, p2: P2, p3: P3, p4: P4) -> Self
pub fn new<P1, P2, P3, P4>(p1: P1, p2: P2, p3: P3, p4: P4) -> Self
Constructs a Quad
with the given Points.
use pix_engine::prelude::*;
let quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
assert_eq!(quad.p1().coords(), [10, 20]);
assert_eq!(quad.p2().coords(), [30, 10]);
assert_eq!(quad.p3().coords(), [20, 25]);
assert_eq!(quad.p4().coords(), [15, 15]);
Source§impl<T: Copy, const N: usize> Quad<T, N>
impl<T: Copy, const N: usize> Quad<T, N>
Sourcepub fn points(&self) -> [Point<T, N>; 4]
pub fn points(&self) -> [Point<T, N>; 4]
Returns Quad
points as [Point<T, N>; 4]
.
§Example
let quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
assert_eq!(quad.points(), [
point!(10, 20),
point!(30, 10),
point!(20, 25),
point!(15, 15)
]);
Sourcepub fn points_mut(&mut self) -> &mut [Point<T, N>; 4]
pub fn points_mut(&mut self) -> &mut [Point<T, N>; 4]
Returns Quad
points as a mutable slice &mut [Point<T, N>; 4]
.
§Example
let mut quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
for p in quad.points_mut() {
*p += 5;
}
assert_eq!(quad.points(), [
point!(15, 25),
point!(35, 15),
point!(25, 30),
point!(20, 20)
]);
Source§impl<T, const N: usize> Quad<T, N>
impl<T, const N: usize> Quad<T, N>
Sourcepub fn as_<U>(&self) -> Quad<U, N>where
U: 'static + Copy,
T: AsPrimitive<U>,
pub fn as_<U>(&self) -> Quad<U, N>where
U: 'static + Copy,
T: AsPrimitive<U>,
Returns Self
with the numbers cast using as
operator.
Converts Quad < T, N > to Quad < U, N >.
Trait Implementations§
Source§impl<'de, T, const N: usize> Deserialize<'de> for Quad<T, N>where
T: Serialize + DeserializeOwned,
impl<'de, T, const N: usize> Deserialize<'de> for Quad<T, N>where
T: Serialize + DeserializeOwned,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a, T, const N: usize> IntoIterator for &'a Quad<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a Quad<T, N>
Source§impl<'a, T, const N: usize> IntoIterator for &'a mut Quad<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a mut Quad<T, N>
Source§impl<T, const N: usize> IntoIterator for Quad<T, N>
impl<T, const N: usize> IntoIterator for Quad<T, N>
impl<T: Copy, const N: usize> Copy for Quad<T, N>
impl<T: Eq, const N: usize> Eq for Quad<T, N>
impl<T, const N: usize> StructuralPartialEq for Quad<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for Quad<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for Quad<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for Quad<T, N>where
T: Send,
impl<T, const N: usize> Sync for Quad<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for Quad<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for Quad<T, N>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.