[−]Struct druid::Point
A 2D point.
Fields
x: f64
The x coordinate.
y: f64
The y coordinate.
Implementations
impl Point
pub const ZERO: Point
The point (0, 0).
pub const ORIGIN: Point
The point at the origin; (0, 0).
pub const fn new(x: f64, y: f64) -> Point
Create a new Point
with the provided x
and y
coordinates.
pub const fn to_vec2(self) -> Vec2
Convert this point into a Vec2
.
pub fn lerp(self, other: Point, t: f64) -> Point
Linearly interpolate between two points.
pub fn midpoint(self, other: Point) -> Point
Determine the midpoint of two points.
pub fn distance(self, other: Point) -> f64
Euclidean distance.
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
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
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
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
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<(f64, f64)> for Point
type Output = Point
The resulting type after applying the +
operator.
pub fn add(self, (f64, f64)) -> Point
impl Add<Vec2> for Point
type Output = Point
The resulting type after applying the +
operator.
pub fn add(self, other: Vec2) -> Point
impl AddAssign<(f64, f64)> for Point
pub fn add_assign(&mut self, (f64, f64))
impl AddAssign<Vec2> for Point
pub fn add_assign(&mut self, other: Vec2)
impl Clone for Point
pub fn clone(&self) -> Point
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Point
impl Data for Point
[src]
impl Debug for Point
impl Default for Point
impl Display for Point
impl From<(f64, f64)> for Point
impl Into<Value> for Point
[src]
impl Mul<Point> for Affine
type Output = Point
The resulting type after applying the *
operator.
pub fn mul(self, other: Point) -> Point
impl Mul<Point> for TranslateScale
type Output = Point
The resulting type after applying the *
operator.
pub fn mul(self, other: Point) -> Point
impl PartialEq<Point> for Point
impl Scalable for Point
[src]
pub fn to_px(&self, scale: Scale) -> Point
[src]
Converts a Point
from display points into pixels,
using the x axis scale factor for x
and the y axis scale factor for y
.
pub fn to_dp(&self, scale: Scale) -> Point
[src]
Converts a Point
from pixels into display points,
using the x axis scale factor for x
and the y axis scale factor for y
.
impl StructuralPartialEq for Point
impl Sub<(f64, f64)> for Point
type Output = Point
The resulting type after applying the -
operator.
pub fn sub(self, (f64, f64)) -> Point
impl Sub<Point> for Point
type Output = Vec2
The resulting type after applying the -
operator.
pub fn sub(self, other: Point) -> Vec2
impl Sub<Vec2> for Point
type Output = Point
The resulting type after applying the -
operator.
pub fn sub(self, other: Vec2) -> Point
impl SubAssign<(f64, f64)> for Point
pub fn sub_assign(&mut self, (f64, f64))
impl SubAssign<Vec2> for Point
pub fn sub_assign(&mut self, other: Vec2)
impl ValueType for Point
[src]
pub fn try_from_value(value: &Value) -> Result<Self, ValueTypeError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Point
[src]
impl Send for Point
[src]
impl Sync for Point
[src]
impl Unpin for Point
[src]
impl UnwindSafe for Point
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AnyEq for T where
T: PartialEq<T> + Any,
[src]
T: PartialEq<T> + Any,
pub fn equals(&self, other: &(dyn Any + 'static)) -> bool
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,