[−][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::unsignedcoord::UnsignedCoord;

let coord = Coord::new(-5, 10);

assert_eq!(coord.to_unsigned(), UnsignedCoord::new(0, 10));

`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 Index<usize> for Coord`[src]

`type Output = i32`

The returned type after indexing.

`impl Clone for Coord`[src]

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

Performs copy-assignment from `source`. Read more

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, 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.