pub struct Point2D<T> {
pub u: T,
pub v: T,
}
Expand description
Represents a 2-dimensional point in space. In this crates context used for uv-mapping.
It can be either created by using the method new
or by using the point
macro.
§Example
use picocadrs::assets::Point2D;
use picocadrs::point;
let mut point = Point2D::new(2, 4);
assert_eq!(point.u, 2);
assert_eq!(point.v, 4);
assert_eq!(point, point!(2, 4));
point.set(1, 2);
assert_eq!(point, point!(1, 2));
assert_eq!(point + point, point!(2, 4));
assert_eq!(point - point, point!(0, 0));
Fields§
§u: T
§v: T
Implementations§
source§impl<T> Point2D<T>
impl<T> Point2D<T>
sourcepub fn new(u: T, v: T) -> Point2D<T>
pub fn new(u: T, v: T) -> Point2D<T>
Used to create new points in a 2-dimensional space.
Takes the points u
and v
coordinates as arguments.
A simpler way to create new Point2D
s is to use the point!
macro.
§Example
use picocadrs::assets::Point2D;
use picocadrs::point;
let point = Point2D::new(2, 4);
assert_eq!(point.u, 2);
assert_eq!(point.v, 4);
assert_eq!(point, point!(2, 4))
Trait Implementations§
source§fn index(&self, index: Point2D<usize>) -> &Self::Output
fn index(&self, index: Point2D<usize>) -> &Self::Output
Panics if u >= 128
or v >= 120
.
§Example
use picocadrs::assets::{Footer, Color, Point2D};
use picocadrs::point;
let footer = Footer::default();
assert_eq!(footer[point!(0, 0)], Color::Black);
assert_eq!(footer[point!(127, 119)], Color::Black);
// assert_eq!(footer[point!(127, 120)], Color::Black); These panic
// assert_eq!(footer[point!(128, 119)], Color::Black);
source§fn index_mut(&mut self, index: Point2D<usize>) -> &mut Self::Output
fn index_mut(&mut self, index: Point2D<usize>) -> &mut Self::Output
Panics if u >= 128
or v >= 120
.
§Example
use picocadrs::assets::{Footer, Color, Point2D};
use picocadrs::point;
let footer = Footer::default();
assert_eq!(footer[point!(0, 0)], Color::Black);
assert_eq!(footer[point!(127, 119)], Color::Black);
// assert_eq!(footer[point!(127, 120)], Color::Black); These panic
// assert_eq!(footer[point!(128, 119)], Color::Black);
source§impl<T: PartialEq> PartialEq for Point2D<T>
impl<T: PartialEq> PartialEq for Point2D<T>
source§impl TryFrom<Table<'_>> for Point2D<f64>
impl TryFrom<Table<'_>> for Point2D<f64>
impl<T: Copy> Copy for Point2D<T>
impl<T: Eq> Eq for Point2D<T>
impl<T> StructuralPartialEq for Point2D<T>
Auto Trait Implementations§
impl<T> Freeze for Point2D<T>where
T: Freeze,
impl<T> RefUnwindSafe for Point2D<T>where
T: RefUnwindSafe,
impl<T> Send for Point2D<T>where
T: Send,
impl<T> Sync for Point2D<T>where
T: Sync,
impl<T> Unpin for Point2D<T>where
T: Unpin,
impl<T> UnwindSafe for Point2D<T>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