[−][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
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
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 ToUnsigned for Coord
[src]
fn to_unsigned(self) -> UnsignedCoord
[src]
Convert to a positive-only coordinate, clamping negative values to zero
use embedded_graphics::coord::Coord;
use embedded_graphics::unsignedcoord::UnsignedCoord;
let coord = Coord::new(-5, 10);
assert_eq!(coord.to_unsigned(), UnsignedCoord::new(0, 10));
impl Debug for Coord
[src]
impl PartialEq<Coord> for Coord
[src]
impl Eq for Coord
[src]
impl Copy for Coord
[src]
impl Add<Coord> for Coord
[src]
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, other: Coord) -> 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 AddAssign<Coord> for Coord
[src]
fn add_assign(&mut self, other: Coord)
[src]
impl SubAssign<Coord> for Coord
[src]
fn sub_assign(&mut self, other: Coord)
[src]
impl Index<usize> for Coord
[src]
impl Clone for Coord
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom 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 for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,