Struct embedded_graphics::coord::Coord [−][src]
pub struct Coord(pub i32, pub i32);
2D coordinate type
Methods
impl Coord
[src]
impl Coord
pub fn new(x: i32, y: i32) -> Self
[src]
pub fn new(x: i32, y: i32) -> Self
Create a new coordinate with X and Y values
pub fn clamp_positive(&self) -> Self
[src]
pub fn clamp_positive(&self) -> Self
Clamp coordinate components to positive integer range
pub fn abs(&self) -> Self
[src]
pub fn abs(&self) -> Self
Remove 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 Coord
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Copy for Coord
[src]
impl Copy for Coord
impl Clone for Coord
[src]
impl Clone for Coord
fn clone(&self) -> Coord
[src]
fn clone(&self) -> Coord
Returns 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 Coord
impl PartialEq for Coord
[src]
impl PartialEq for Coord
fn eq(&self, other: &Coord) -> bool
[src]
fn eq(&self, other: &Coord) -> bool
This 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) -> bool
This method tests for !=
.
impl Add for Coord
[src]
impl Add for Coord
type Output = Coord
The resulting type after applying the +
operator.
fn add(self, other: Coord) -> Coord
[src]
fn add(self, other: Coord) -> Coord
Performs the +
operation.
impl AddAssign for Coord
[src]
impl AddAssign for Coord
fn 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 Coord
type Output = Coord
The resulting type after applying the -
operator.
fn sub(self, other: Coord) -> Coord
[src]
fn sub(self, other: Coord) -> Coord
Performs the -
operation.
impl SubAssign for Coord
[src]
impl SubAssign for Coord
fn 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 Coord
type Output = i32
The returned type after indexing.
fn index(&self, idx: usize) -> &i32
[src]
fn index(&self, idx: usize) -> &i32
Performs the indexing (container[index]
) operation.
impl ToUnsigned for Coord
[src]
impl ToUnsigned for Coord
fn to_unsigned(self) -> UnsignedCoord
[src]
fn to_unsigned(self) -> UnsignedCoord
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));