pub struct Coord(pub i32, pub i32);
Expand description

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

Tuple Fields

0: i321: i32

Implementations

Create a new coordinate with X and Y values

Clamp coordinate components to positive integer range

Remove the sign from a coordinate

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

assert_eq!(coord.abs(), Coord::new(5, 10));

Trait Implementations

The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more

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));

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.