Struct kurbo::Point [−][src]
Expand description
A 2D point.
Fields
x: f64
The x coordinate.
y: f64
The y coordinate.
Implementations
Create a new Point
with the provided x
and y
coordinates.
Squared Euclidean distance.
Returns a new Point
,
with x
and y
rounded to the nearest integer.
Examples
use kurbo::Point;
let a = Point::new(3.3, 3.6).round();
let b = Point::new(3.0, -3.1).round();
assert_eq!(a.x, 3.0);
assert_eq!(a.y, 4.0);
assert_eq!(b.x, 3.0);
assert_eq!(b.y, -3.0);
Returns a new Point
,
with x
and y
rounded up to the nearest integer,
unless they are already an integer.
Examples
use kurbo::Point;
let a = Point::new(3.3, 3.6).ceil();
let b = Point::new(3.0, -3.1).ceil();
assert_eq!(a.x, 4.0);
assert_eq!(a.y, 4.0);
assert_eq!(b.x, 3.0);
assert_eq!(b.y, -3.0);
Returns a new Point
,
with x
and y
rounded down to the nearest integer,
unless they are already an integer.
Examples
use kurbo::Point;
let a = Point::new(3.3, 3.6).floor();
let b = Point::new(3.0, -3.1).floor();
assert_eq!(a.x, 3.0);
assert_eq!(a.y, 3.0);
assert_eq!(b.x, 3.0);
assert_eq!(b.y, -4.0);
Returns a new Point
,
with x
and y
rounded away from zero to the nearest integer,
unless they are already an integer.
Examples
use kurbo::Point;
let a = Point::new(3.3, 3.6).expand();
let b = Point::new(3.0, -3.1).expand();
assert_eq!(a.x, 4.0);
assert_eq!(a.y, 4.0);
assert_eq!(b.x, 3.0);
assert_eq!(b.y, -4.0);
Returns a new Point
,
with x
and y
rounded towards zero to the nearest integer,
unless they are already an integer.
Examples
use kurbo::Point;
let a = Point::new(3.3, 3.6).trunc();
let b = Point::new(3.0, -3.1).trunc();
assert_eq!(a.x, 3.0);
assert_eq!(a.y, 3.0);
assert_eq!(b.x, 3.0);
assert_eq!(b.y, -3.0);
Trait Implementations
Performs the +=
operation. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Point
impl UnwindSafe for Point
Blanket Implementations
Mutably borrows from an owned value. Read more