Struct pix_engine::shape::Quad [−][src]
#[repr(transparent)]pub struct Quad<T, const N: usize>(_);
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
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().as_array(), [10, 20]);
assert_eq!(quad.p2().as_array(), [30, 10]);
assert_eq!(quad.p3().as_array(), [20, 25]);
assert_eq!(quad.p4().as_array(), [15, 15]);
Sets the first point of the quad.
Sets the second point of the quad.
Sets the third point of the quad.
Sets the fourth point of the quad.
Returns Quad
points as [Point<T, N>; 4]
.
Example
let quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
assert_eq!(quad.as_array(), [
point!(10, 20),
point!(30, 10),
point!(20, 25),
point!(15, 15)
]);
Returns Quad
points as a byte slice &[Point<T, N>; 4]
.
Example
let quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
assert_eq!(quad.as_bytes(), &[
point!(10, 20),
point!(30, 10),
point!(20, 25),
point!(15, 15)
]);
Returns Quad
points as a mutable byte slice &mut [Point<T, N>; 4]
.
Example
let mut quad = Quad::new([10, 20], [30, 10], [20, 25], [15, 15]);
for p in quad.as_bytes_mut() {
*p += 5;
}
assert_eq!(quad.as_bytes(), &[
point!(15, 25),
point!(35, 15),
point!(25, 30),
point!(20, 20)
]);
Returns Self
with the numbers cast using as
operator.
Converts Quad < T, N > to Quad < U, N >.
Returns Quad < T, N > with the nearest integers to the numbers. Round half-way cases away from 0.0.
Returns Quad < T, N >with the largest integers less than or equal to the numbers.
Trait Implementations
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,
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
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T, const N: usize> RefUnwindSafe for Quad<T, N> where
T: RefUnwindSafe,
impl<T, const N: usize> UnwindSafe for Quad<T, N> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more