Skip to main content

PathSegment

Enum PathSegment 

Source
pub enum PathSegment {
    Line {
        from: C64,
        to: C64,
    },
    Arc {
        centre: C64,
        radius: f64,
        start_angle: f64,
        end_angle: f64,
    },
    Curve {
        z: Rc<dyn Fn(f64) -> C64>,
        dz: Rc<dyn Fn(f64) -> C64>,
        t0: f64,
        t1: f64,
    },
}
Expand description

One smooth piece of a contour.

Variants§

§

Line

The straight segment from from to to.

Fields

§from: C64
§to: C64
§

Arc

The circular arc centre + radius·e^{iθ} for θ from start_angle to end_angle (radians; counter-clockwise when end_angle > start_angle).

Fields

§centre: C64
§radius: f64
§start_angle: f64
§end_angle: f64
§

Curve

A parametrised curve z(t) for t in [t0, t1] with derivative dz(t).

Fields

§z: Rc<dyn Fn(f64) -> C64>
§dz: Rc<dyn Fn(f64) -> C64>
§t0: f64
§t1: f64

Implementations§

Source§

impl PathSegment

Source

pub fn line(from: C64, to: C64) -> Self

The straight segment from from to to.

Source

pub fn circle(centre: C64, radius: f64) -> Self

The full counter-clockwise circle, starting and ending at angle 0.

Source

pub fn arc(centre: C64, radius: f64, start_angle: f64, end_angle: f64) -> Self

The circular arc centre + radius·e^{iθ}, θ from start_angle to end_angle (radians).

Source

pub fn curve( z: impl Fn(f64) -> C64 + 'static, dz: impl Fn(f64) -> C64 + 'static, t0: f64, t1: f64, ) -> Self

The curve z(t), t from t0 to t1, with its derivative dz(t) = z'(t).

Source

pub fn start(&self) -> C64

The first point of the segment.

Source

pub fn end(&self) -> C64

The last point of the segment.

Source

pub fn point_at(&self, s: f64) -> C64

The point at fraction s in [0, 1] of the parameter range.

Trait Implementations§

Source§

impl Clone for PathSegment

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PathSegment

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.