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 HasTransformedView for Point
impl HasTransformedView for Point
§type TransformedView = Point
type TransformedView = Point
An object storing a transformed view of
Self
.source§fn transformed_view(
&self,
trans: Transformation
) -> <Point as HasTransformedView>::TransformedView
fn transformed_view( &self, trans: Transformation ) -> <Point as HasTransformedView>::TransformedView
Produces a transformed view of
self
.source§impl Ord for Point
impl Ord for Point
source§impl PartialEq for Point
impl PartialEq for Point
source§impl PartialOrd for Point
impl PartialOrd for Point
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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 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.impl Copy for Point
impl Eq for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Flipped<T>) -> U
fn from_layout_type(other: &Flipped<T>) -> U
Creates this layout type from another layout type.
source§impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &InOut<T>) -> U
fn from_layout_type(other: &InOut<T>) -> U
Creates this layout type from another layout type.
source§impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Input<T>) -> U
fn from_layout_type(other: &Input<T>) -> U
Creates this layout type from another layout type.
source§impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Output<T>) -> U
fn from_layout_type(other: &Output<T>) -> U
Creates this layout type from another layout type.
§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>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<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>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§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<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