Point

Struct Point 

Source
pub struct Point<PD: PointData> {
    pub x: f32,
    pub y: f32,
    pub a: Handle,
    pub b: Handle,
    pub name: Option<String>,
    pub ptype: PointType,
    pub smooth: bool,
    pub data: Option<PD>,
}
Expand description

A Skia-friendly point

Fields§

§x: f32§y: f32§a: Handle§b: Handle§name: Option<String>§ptype: PointType§smooth: bool§data: Option<PD>

Implementations§

Source§

impl<PD: PointData> Point<PD>

Source

pub fn new() -> Point<PD>

Source

pub fn from_x_y_type((x, y): (f32, f32), ptype: PointType) -> Point<PD>

Make a point from its x and y position and type

Source

pub fn from_x_y_a_b_type( (x, y): (f32, f32), (a, b): (Handle, Handle), ptype: PointType, ) -> Point<PD>

Make a point from its x and y position, handles and type

Source

pub fn from_fields( (x, y): (f32, f32), (a, b): (Handle, Handle), smooth: bool, ptype: PointType, name: Option<String>, data: Option<PD>, ) -> Point<PD>

Make a point from its x and y position, handles and type

Source

pub fn handle(&self, which: WhichHandle) -> Handle

Source

pub fn handle_or_colocated( &self, which: WhichHandle, transform_x: &dyn Fn(f32) -> f32, transform_y: &dyn Fn(f32) -> f32, ) -> (f32, f32)

Return an x, y position for a point, or one of its handles. If called with WhichHandle::Neither, return position for point.

Source

pub fn handle_as_gpoint(&self, which: WhichHandle) -> GlifPoint

Source

pub fn handle_as_point(&self, which: WhichHandle) -> Self

Source

pub fn handle_as_kpoint(&self, which: WhichHandle) -> KurboPoint

Source

pub fn set_handle(&mut self, which: WhichHandle, handle: Handle)

This function is intended for use by generic functions that can work on either handle, to decrease the use of macros like move_mirror!(a, b).

Trait Implementations§

Source§

impl<PD: PointData> ApplyMatrix for Point<PD>

Source§

fn apply_matrix(&mut self, matrix: Affine)

Source§

impl<PD: Clone + PointData> Clone for Point<PD>

Source§

fn clone(&self) -> Point<PD>

Returns a duplicate 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<PD: Debug + PointData> Debug for Point<PD>

Source§

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

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

impl<PD: Default + PointData> Default for Point<PD>

Source§

fn default() -> Point<PD>

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

impl<'de, PD> Deserialize<'de> for Point<PD>
where PD: Deserialize<'de> + Default + PointData,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<PD: PointData> From<&GlifPoint> for Point<PD>

Source§

fn from(gp: &GlifPoint) -> Self

Converts to this type from the input type.
Source§

impl<PD: PointData> From<&Point<PD>> for GlifPoint

Warning: you lose handles with this.

Source§

fn from(p: &Point<PD>) -> GlifPoint

Converts to this type from the input type.
Source§

impl<PD: PointData> From<&Point<PD>> for Handle

Source§

fn from(p: &Point<PD>) -> Handle

Converts to this type from the input type.
Source§

impl<PD: PointData> IsValid for Point<PD>

Source§

fn is_valid(&self) -> bool

validate_data parameter allows you to define an is_valid (or whatever) impl on your PointData struct’s. You can then pass the function while validating the point as e.g. Some(MyPointData::is_valid). It takes an Option<&PD> so that you have the choice as to whether it’s valid or not for your type not to be defined; Point.data should probably not be defined as an Option, but removing that’s TODO. This API will change when that does and should be considered unstable/testing.

Source§

fn expect_valid(&self)

Source§

impl<PD: PointData> MFEKPointCommon<PD> for Point<PD>

Source§

fn has_handle(&self, _handle: WhichHandle) -> bool

Source§

fn get_handle(&self, handle: WhichHandle) -> Option<Handle>

Source§

fn get_handle_position(&self, handle: WhichHandle) -> Option<(f32, f32)>

Source§

fn set_handle_position(&mut self, handle: WhichHandle, x: f32, y: f32)

Source§

fn set_handle(&mut self, wh: WhichHandle, handle: Handle)

Source§

fn get_position(&self) -> (f32, f32)

Source§

fn set_position(&mut self, x: f32, y: f32)

Source§

fn set_position_no_handles(&mut self, x: f32, y: f32)

Source§

fn x(&self) -> f32

Source§

fn y(&self) -> f32

Source§

fn get_name(&self) -> Option<String>

Source§

fn set_name(&mut self, name: String)

Source§

fn cubic(&self) -> Option<&Point<PD>>

Source§

fn quad(&self) -> Option<&QPoint<PD>>

Source§

fn hyper(&self) -> Option<&HyperPoint<PD>>

Source§

fn colocate_handle(&mut self, wh: WhichHandle)

Source§

impl<PD: PartialEq + PointData> PartialEq for Point<PD>

Source§

fn eq(&self, other: &Point<PD>) -> 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<PD: PointData> PointLike for Point<PD>

Source§

fn x(&self) -> IntegerOrFloat

Source§

fn y(&self) -> IntegerOrFloat

Source§

fn set_x(&mut self, x: IntegerOrFloat)

Source§

fn set_y(&mut self, y: IntegerOrFloat)

Source§

fn x32(&self) -> f32

Source§

fn y32(&self) -> f32

Source§

fn x64(&self) -> f64

Source§

fn y64(&self) -> f64

Source§

fn as_kpoint(&self) -> KurboPoint

Source§

impl<PD: PointData> RoundToInt for Point<PD>

Source§

fn round_to_int(&mut self)

Source§

impl<PD> Serialize for Point<PD>
where PD: Serialize + PointData,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<PD: PointData> StructuralPartialEq for Point<PD>

Auto Trait Implementations§

§

impl<PD> Freeze for Point<PD>
where PD: Freeze,

§

impl<PD> RefUnwindSafe for Point<PD>
where PD: RefUnwindSafe,

§

impl<PD> Send for Point<PD>
where PD: Send,

§

impl<PD> Sync for Point<PD>
where PD: Sync,

§

impl<PD> Unpin for Point<PD>
where PD: Unpin,

§

impl<PD> UnwindSafe for Point<PD>
where PD: UnwindSafe,

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, dest: *mut u8)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> TupleTree<T, ()> for T

Source§

const SIZE: Size

Source§

fn descendants(_indirect_level: usize) -> usize

Source§

fn height() -> usize

Source§

fn preorder(self, f: &mut impl FnMut(Visit<T>))

Source§

fn preorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

Source§

fn postorder(self, f: &mut impl FnMut(Visit<T>))

Source§

fn postorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

Source§

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