Struct embedded_graphics::coord::Coord [−][src]
pub struct Coord(pub i32, pub i32);
2D coordinate type
Methods
impl Coord[src]
impl Coordpub fn new(x: i32, y: i32) -> Self[src]
pub fn new(x: i32, y: i32) -> SelfCreate a new coordinate with X and Y values
pub fn clamp_positive(&self) -> Self[src]
pub fn clamp_positive(&self) -> SelfClamp coordinate components to positive integer range
pub fn abs(&self) -> Self[src]
pub fn abs(&self) -> SelfRemove the sign from a coordinate
let coord = Coord::new(-5, -10); assert_eq!(coord.abs(), Coord::new(5, 10));
Trait Implementations
impl Debug for Coord[src]
impl Debug for Coordfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Copy for Coord[src]
impl Copy for Coordimpl Clone for Coord[src]
impl Clone for Coordfn clone(&self) -> Coord[src]
fn clone(&self) -> CoordReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Eq for Coord[src]
impl Eq for Coordimpl PartialEq for Coord[src]
impl PartialEq for Coordfn eq(&self, other: &Coord) -> bool[src]
fn eq(&self, other: &Coord) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Coord) -> bool[src]
fn ne(&self, other: &Coord) -> boolThis method tests for !=.
impl Add for Coord[src]
impl Add for Coordtype Output = Coord
The resulting type after applying the + operator.
fn add(self, other: Coord) -> Coord[src]
fn add(self, other: Coord) -> CoordPerforms the + operation.
impl AddAssign for Coord[src]
impl AddAssign for Coordfn add_assign(&mut self, other: Coord)[src]
fn add_assign(&mut self, other: Coord)Performs the += operation.
impl Sub for Coord[src]
impl Sub for Coordtype Output = Coord
The resulting type after applying the - operator.
fn sub(self, other: Coord) -> Coord[src]
fn sub(self, other: Coord) -> CoordPerforms the - operation.
impl SubAssign for Coord[src]
impl SubAssign for Coordfn sub_assign(&mut self, other: Coord)[src]
fn sub_assign(&mut self, other: Coord)Performs the -= operation.
impl Index<usize> for Coord[src]
impl Index<usize> for Coordtype Output = i32
The returned type after indexing.
fn index(&self, idx: usize) -> &i32[src]
fn index(&self, idx: usize) -> &i32Performs the indexing (container[index]) operation.
impl ToUnsigned for Coord[src]
impl ToUnsigned for Coordfn to_unsigned(self) -> UnsignedCoord[src]
fn to_unsigned(self) -> UnsignedCoordConvert 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));