[−][src]Struct embedded_graphics::coord::Coord
2D signed integer coordinate type
This coordinate should be used to define graphics object coordinates. For example, a
Rect
may be defined that has its top left at (-1,-2)
. To specify positive-only screen
coordinates and the like, see UnsignedCoord
.
use embedded_graphics::{coord::Coord, icoord}; // Create a coord using the `new` constructor method let c1 = Coord::new(10, 20); // Create a coord using the handy `icoord` macro let c2 = icoord!(10, 20); assert_eq!(c1, c2);
Note that enabling the nalgebra
feature will alias Nalgebra's Vector2<i32>
type to
Coord
instead of this builtin implementation.
Methods
impl Coord
[src]
pub fn new(x: i32, y: i32) -> Self
[src]
Create a new coordinate with X and Y values
pub fn clamp_positive(&self) -> Self
[src]
Clamp coordinate components to positive integer range
let coord = Coord::new(-5, 10); assert_eq!(coord.clamp_positive(), Coord::new(0, 10));
pub fn abs(&self) -> Self
[src]
Remove the sign from a coordinate
let coord = Coord::new(-5, -10); assert_eq!(coord.abs(), Coord::new(5, 10));
Trait Implementations
impl Add<Coord> for Coord
[src]
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, other: Coord) -> Coord
[src]
impl AddAssign<Coord> for Coord
[src]
fn add_assign(&mut self, other: Coord)
[src]
impl Clone for Coord
[src]
fn clone(&self) -> Coord
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Coord
[src]
impl Debug for Coord
[src]
impl Eq for Coord
[src]
impl<'_> From<&'_ [i32; 2]> for Coord
[src]
impl<'_> From<&'_ [u32; 2]> for Coord
[src]
impl<'_> From<&'_ Coord> for (i32, i32)
[src]
impl From<[i32; 2]> for Coord
[src]
impl From<[u32; 2]> for Coord
[src]
impl From<(i32, i32)> for Coord
[src]
impl From<(u32, u32)> for Coord
[src]
impl From<Coord> for (i32, i32)
[src]
impl Index<usize> for Coord
[src]
impl Neg for Coord
[src]
type Output = Coord
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl PartialEq<Coord> for Coord
[src]
impl StructuralEq for Coord
[src]
impl StructuralPartialEq for Coord
[src]
impl Sub<Coord> for Coord
[src]
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, other: Coord) -> Coord
[src]
impl SubAssign<Coord> for Coord
[src]
fn sub_assign(&mut self, other: Coord)
[src]
impl ToUnsigned for Coord
[src]
fn to_unsigned(self) -> UnsignedCoord
[src]
Convert to a positive-only coordinate, clamping negative values to zero
let coord = Coord::new(-5, 10); assert_eq!(coord.to_unsigned(), UnsignedCoord::new(0, 10));
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,