pub struct Point {
pub x: i64,
pub y: i64,
}
Expand description
A point in two-dimensional space.
Fields§
§x: i64
The x-coordinate of the point.
y: i64
The y-coordinate of the point.
Implementations§
Source§impl Point
impl Point
Sourcepub const fn from_dir_coords(dir: Dir, a: i64, b: i64) -> Point
pub const fn from_dir_coords(dir: Dir, a: i64, b: i64) -> Point
Creates a new point from the given direction and coordinates.
If dir
is Dir::Horiz
, a
becomes the x-coordinate and b
becomes the y-coordinate.
If dir
is Dir::Vert
, a
becomes the y-coordinate and b
becomes the x-coordinate.
Sourcepub const fn zero() -> Point
pub const fn zero() -> Point
Returns the origin, (0, 0)
.
§Example
let origin = Point::zero();
assert_eq!(origin, Point::new(0, 0));
Sourcepub fn snap_to_grid(&self, grid: i64) -> Point
pub fn snap_to_grid(&self, grid: i64) -> Point
Snaps the x and y coordinates of this point to the nearest multiple of grid
.
Sourcepub fn snap_x_to_grid(&self, grid: i64) -> Point
pub fn snap_x_to_grid(&self, grid: i64) -> Point
Snaps only the x-coordinate of this point to the nearest multiple of grid
.
Sourcepub fn snap_y_to_grid(&self, grid: i64) -> Point
pub fn snap_y_to_grid(&self, grid: i64) -> Point
Snaps only the y-coordinate of this point to the nearest multiple of grid
.
Trait Implementations§
Source§impl AddAssign<Dims> for Point
impl AddAssign<Dims> for Point
Source§fn add_assign(&mut self, rhs: Dims)
fn add_assign(&mut self, rhs: Dims)
Performs the
+=
operation. Read moreSource§impl AddAssign for Point
impl AddAssign for Point
Source§fn add_assign(&mut self, rhs: Point)
fn add_assign(&mut self, rhs: Point)
Performs the
+=
operation. Read moreSource§impl Contains<Point> for Polygon
impl Contains<Point> for Polygon
Source§fn contains(&self, p: &Point) -> Containment
fn contains(&self, p: &Point) -> Containment
Determines if a point is contained within a polygon.
§Example
let points = vec![
Point { x: -4, y: 0 },
Point { x: 0, y: 0 },
Point { x: 1, y: 2 },
Point { x: 2, y: 2 },
Point { x: -4, y: 5 },
];
let p1 = Point::new(0,0);
let p2 = Point::new(0,4);
let p3 = Point::new(-5,3);
let p4 = Point::new(-2,4);
let p5 = Point::new(-2,2);
let polygon = Polygon::from_verts(points);
assert_eq!(polygon.contains(&p1), Containment::Full);
assert_eq!(polygon.contains(&p2), Containment::None);
assert_eq!(polygon.contains(&p3), Containment::None);
assert_eq!(polygon.contains(&p4), Containment::Full);
assert_eq!(polygon.contains(&p5), Containment::Full);
Source§fn partially_intersects(&self, other: &T) -> bool
fn partially_intersects(&self, other: &T) -> bool
Returns true if
other
is fully or partially enclosed in this shape.Source§impl Contains<Point> for Rect
impl Contains<Point> for Rect
Source§fn contains(&self, other: &Point) -> Containment
fn contains(&self, other: &Point) -> Containment
Source§fn partially_intersects(&self, other: &T) -> bool
fn partially_intersects(&self, other: &T) -> bool
Returns true if
other
is fully or partially enclosed in this shape.Source§impl Contains<Point> for Ring
impl Contains<Point> for Ring
Source§fn contains(&self, other: &Point) -> Containment
fn contains(&self, other: &Point) -> Containment
Source§fn partially_intersects(&self, other: &T) -> bool
fn partially_intersects(&self, other: &T) -> bool
Returns true if
other
is fully or partially enclosed in this shape.Source§impl Contains<Point> for Shape
impl Contains<Point> for Shape
Source§fn contains(&self, p: &Point) -> Containment
fn contains(&self, p: &Point) -> Containment
Source§fn partially_intersects(&self, other: &T) -> bool
fn partially_intersects(&self, other: &T) -> bool
Returns true if
other
is fully or partially enclosed in this shape.Source§impl<'de> Deserialize<'de> for Point
impl<'de> Deserialize<'de> for Point
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Point, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Point, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Mul<Point> for TransformationMatrix
impl Mul<Point> for TransformationMatrix
Source§impl Ord for Point
impl Ord for Point
Source§impl PartialOrd for Point
impl PartialOrd for Point
Source§impl Serialize for Point
impl Serialize for Point
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl SubAssign for Point
impl SubAssign for Point
Source§fn sub_assign(&mut self, rhs: Point)
fn sub_assign(&mut self, rhs: Point)
Performs the
-=
operation. Read moreSource§impl TransformMut for Point
impl TransformMut for Point
Source§fn transform_mut(&mut self, trans: Transformation)
fn transform_mut(&mut self, trans: Transformation)
Applies matrix-vector
Transformation
trans
.Source§impl TransformRef for Point
impl TransformRef for Point
Source§fn transform_ref(&self, trans: Transformation) -> Point
fn transform_ref(&self, trans: Transformation) -> Point
Applies matrix-vector
Transformation
trans
.Source§impl TranslateMut for Point
impl TranslateMut for Point
Source§fn translate_mut(&mut self, p: Point)
fn translate_mut(&mut self, p: Point)
Translates the shape by a
Point
through mutation.Source§impl TranslateRef for Point
impl TranslateRef for Point
impl Copy for Point
impl Eq for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> AlignRect for Twhere
T: AlignRectMut,
impl<T> AlignRect for Twhere
T: AlignRectMut,
Source§impl<T> AlignRectMut for Twhere
T: Translate,
impl<T> AlignRectMut for Twhere
T: Translate,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request