[][src]Struct embedded_graphics::prelude::Coord

pub struct Coord(pub i32, pub i32);

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 Clone for Coord[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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.

impl Sub<Coord> for Coord[src]

type Output = Coord

The resulting type after applying the - operator.

impl AddAssign<Coord> for Coord[src]

impl SubAssign<Coord> for Coord[src]

impl Index<usize> for Coord[src]

type Output = i32

The returned type after indexing.

Auto Trait Implementations

impl Send for Coord

impl Sync for Coord

Blanket Implementations

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> From for T[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]