[][src]Struct kurbo::Point

pub struct Point {
    pub x: f64,
    pub y: f64,
}

A 2D point.

Fields

x: f64

The x coordinate.

y: f64

The y coordinate.

Implementations

impl Point[src]

pub const ZERO: Point[src]

The point (0, 0).

pub const ORIGIN: Point[src]

The point at the origin; (0, 0).

pub const fn new(x: f64, y: f64) -> Self[src]

Create a new Point with the provided x and y coordinates.

pub const fn to_vec2(self) -> Vec2[src]

Convert this point into a Vec2.

pub fn lerp(self, other: Point, t: f64) -> Point[src]

Linearly interpolate between two points.

pub fn midpoint(self, other: Point) -> Point[src]

Determine the midpoint of two points.

pub fn distance(self, other: Point) -> f64[src]

Euclidean distance.

pub fn round(self) -> Point[src]

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[src]

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[src]

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[src]

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[src]

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 Add<Vec2> for Point[src]

type Output = Point

The resulting type after applying the + operator.

impl AddAssign<Vec2> for Point[src]

impl Clone for Point[src]

impl Copy for Point[src]

impl Debug for Point[src]

impl Default for Point[src]

impl<'de> Deserialize<'de> for Point[src]

impl Display for Point[src]

impl From<(f64, f64)> for Point[src]

impl From<Point> for (f64, f64)[src]

impl From<Point> for Point2<f64>[src]

impl From<Point2<f64>> for Point[src]

impl Mul<Point> for Affine[src]

type Output = Point

The resulting type after applying the * operator.

impl Mul<Point> for TranslateScale[src]

type Output = Point

The resulting type after applying the * operator.

impl PartialEq<Point> for Point[src]

impl Serialize for Point[src]

impl StructuralPartialEq for Point[src]

impl Sub<Point> for Point[src]

type Output = Vec2

The resulting type after applying the - operator.

impl Sub<Vec2> for Point[src]

type Output = Point

The resulting type after applying the - operator.

impl SubAssign<Vec2> for Point[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.