Struct tiny_skia_path::Point

source ·
#[repr(C)]
pub struct Point { pub x: f32, pub y: f32, }
Expand description

A point.

Doesn’t guarantee to be finite.

Fields§

§x: f32§y: f32

Implementations§

source§

impl Point

source

pub fn from_xy(x: f32, y: f32) -> Self

Creates a new Point.

source

pub fn from_f32x2(r: f32x2) -> Self

Creates a new Point from f32x2.

source

pub fn to_f32x2(&self) -> f32x2

Converts a Point into a f32x2.

source

pub fn zero() -> Self

Creates a point at 0x0 position.

source

pub fn is_zero(&self) -> bool

Returns true if x and y are both zero.

source

pub fn is_finite(&self) -> bool

Returns true if both x and y are measurable values.

Both values are other than infinities and NaN.

source

pub(crate) fn almost_equal(&self, other: Point) -> bool

Checks that two Points are almost equal.

source

pub(crate) fn equals_within_tolerance( &self, other: Point, tolerance: f32, ) -> bool

Checks that two Points are almost equal using the specified tolerance.

source

pub fn normalize(&mut self) -> bool

Scales (fX, fY) so that length() returns one, while preserving ratio of fX to fY, if possible.

If prior length is nearly zero, sets vector to (0, 0) and returns false; otherwise returns true.

source

pub fn set_normalize(&mut self, x: f32, y: f32) -> bool

Sets vector to (x, y) scaled so length() returns one, and so that (x, y) is proportional to (x, y).

If (x, y) length is nearly zero, sets vector to (0, 0) and returns false; otherwise returns true.

source

pub(crate) fn can_normalize(&self) -> bool

source

pub fn length(&self) -> f32

Returns the Euclidean distance from origin.

source

pub fn set_length(&mut self, length: f32) -> bool

Scales vector so that distanceToOrigin() returns length, if possible.

If former length is nearly zero, sets vector to (0, 0) and return false; otherwise returns true.

source

pub fn set_length_from(&mut self, x: f32, y: f32, length: f32) -> bool

Sets vector to (x, y) scaled to length, if possible.

If former length is nearly zero, sets vector to (0, 0) and return false; otherwise returns true.

source

pub fn distance(&self, other: Point) -> f32

Returns the Euclidean distance from origin.

source

pub fn dot(&self, other: Point) -> f32

Returns the dot product of two points.

source

pub fn cross(&self, other: Point) -> f32

Returns the cross product of vector and vec.

Vector and vec form three-dimensional vectors with z-axis value equal to zero. The cross product is a three-dimensional vector with x-axis and y-axis values equal to zero. The cross product z-axis component is returned.

source

pub(crate) fn distance_to_sqd(&self, pt: Point) -> f32

source

pub(crate) fn length_sqd(&self) -> f32

source

pub fn scale(&mut self, scale: f32)

Scales Point in-place by scale.

source

pub(crate) fn scaled(&self, scale: f32) -> Self

source

pub(crate) fn swap_coords(&mut self)

source

pub(crate) fn rotate_cw(&mut self)

source

pub(crate) fn rotate_ccw(&mut self)

Trait Implementations§

source§

impl Add for Point

source§

type Output = Point

The resulting type after applying the + operator.
source§

fn add(self, other: Point) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign for Point

source§

fn add_assign(&mut self, other: Point)

Performs the += operation. Read more
source§

impl Clone for Point

source§

fn clone(&self) -> Point

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Point

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Point

source§

fn default() -> Point

Returns the “default value” for a type. Read more
source§

impl From<(f32, f32)> for Point

source§

fn from(v: (f32, f32)) -> Self

Converts to this type from the input type.
source§

impl Mul for Point

source§

type Output = Point

The resulting type after applying the * operator.
source§

fn mul(self, other: Point) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign for Point

source§

fn mul_assign(&mut self, other: Point)

Performs the *= operation. Read more
source§

impl Neg for Point

source§

type Output = Point

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for Point

source§

fn eq(&self, other: &Point) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub for Point

source§

type Output = Point

The resulting type after applying the - operator.
source§

fn sub(self, other: Point) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign for Point

source§

fn sub_assign(&mut self, other: Point)

Performs the -= operation. Read more
source§

impl Copy for Point

source§

impl StructuralPartialEq for Point

Auto Trait Implementations§

§

impl Freeze for Point

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.