Struct piet_common::kurbo::Point
Expand description
A 2D point.
Fields
x: f64The x coordinate.
y: f64The y coordinate.
Implementations
impl Point
impl Point
pub fn distance_squared(self, other: Point) -> f64
pub fn distance_squared(self, other: Point) -> f64
Squared Euclidean distance.
pub fn round(self) -> Point
pub fn round(self) -> Point
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);pub fn ceil(self) -> Point
pub fn ceil(self) -> Point
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);pub fn floor(self) -> Point
pub fn floor(self) -> Point
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);pub fn expand(self) -> Point
pub fn expand(self) -> Point
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);pub fn trunc(self) -> Point
pub fn trunc(self) -> Point
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
impl AddAssign<(f64, f64)> for Point
impl AddAssign<(f64, f64)> for Point
fn add_assign(&mut self, _: (f64, f64))
fn add_assign(&mut self, _: (f64, f64))
Performs the
+= operation. Read moreimpl AddAssign<Vec2> for Point
impl AddAssign<Vec2> for Point
fn add_assign(&mut self, other: Vec2)
fn add_assign(&mut self, other: Vec2)
Performs the
+= operation. Read moreimpl Mul<Point> for TranslateScale
impl Mul<Point> for TranslateScale
impl SubAssign<(f64, f64)> for Point
impl SubAssign<(f64, f64)> for Point
fn sub_assign(&mut self, _: (f64, f64))
fn sub_assign(&mut self, _: (f64, f64))
Performs the
-= operation. Read moreimpl SubAssign<Vec2> for Point
impl SubAssign<Vec2> for Point
fn sub_assign(&mut self, other: Vec2)
fn sub_assign(&mut self, other: Vec2)
Performs the
-= operation. Read moreimpl Copy 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
sourcefn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
sourceimpl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
sourcefn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.