Skip to main content

Path

Struct Path 

Source
pub struct Path {
    pub curve_path: CurvePath<Vector2>,
    pub current_point: Vector2,
}
Expand description

Path: a 2D CurvePath with a canvas-like drawing API (moveTo, lineTo, bezierCurveTo, …).

three.js’ Path extends CurvePath; here a Path holds its CurvePath and derefs to it, so path.curves, path.auto_close and path.close_path() read as they do in JavaScript. The builder methods return &mut Self for chaining, as three.js’ return this.

Fields§

§curve_path: CurvePath<Vector2>

The inherited CurvePath state.

§current_point: Vector2

The current offset of the path. Any new curve added will start here.

Implementations§

Source§

impl Path

Source

pub fn new() -> Self

new Path().

Source

pub fn from_points(points: &[Vector2]) -> Self

new Path( points ): setFromPoints( points ) on a new path.

Source

pub fn set_from_points(&mut self, points: &[Vector2]) -> &mut Self

Path.setFromPoints( points ): a moveTo to the first point and a lineTo to each of the rest.

Source

pub fn move_to(&mut self, x: f64, y: f64) -> &mut Self

Path.moveTo( x, y ).

Source

pub fn line_to(&mut self, x: f64, y: f64) -> &mut Self

Path.lineTo( x, y ).

Source

pub fn quadratic_curve_to( &mut self, a_c_px: f64, a_c_py: f64, a_x: f64, a_y: f64, ) -> &mut Self

Path.quadraticCurveTo( aCPx, aCPy, aX, aY ).

Source

pub fn bezier_curve_to( &mut self, a_cp1x: f64, a_cp1y: f64, a_cp2x: f64, a_cp2y: f64, a_x: f64, a_y: f64, ) -> &mut Self

Path.bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ).

Source

pub fn spline_thru(&mut self, pts: &[Vector2]) -> &mut Self

Path.splineThru( pts ): a SplineCurve from the current point through pts.

Source

pub fn arc( &mut self, a_x: f64, a_y: f64, a_radius: f64, a_start_angle: f64, a_end_angle: f64, a_clockwise: bool, ) -> &mut Self

Path.arc( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ): absarc with the center relative to the current point.

Source

pub fn absarc( &mut self, a_x: f64, a_y: f64, a_radius: f64, a_start_angle: f64, a_end_angle: f64, a_clockwise: bool, ) -> &mut Self

Path.absarc( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ).

Source

pub fn ellipse( &mut self, a_x: f64, a_y: f64, x_radius: f64, y_radius: f64, a_start_angle: f64, a_end_angle: f64, a_clockwise: bool, a_rotation: f64, ) -> &mut Self

Path.ellipse( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ): absellipse with the center relative to the current point.

Source

pub fn absellipse( &mut self, a_x: f64, a_y: f64, x_radius: f64, y_radius: f64, a_start_angle: f64, a_end_angle: f64, a_clockwise: bool, a_rotation: f64, ) -> &mut Self

Path.absellipse( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ). Joins the previous curve to the ellipse’s start with a line when they do not meet.

Methods from Deref<Target = CurvePath<Vector2>>§

Source

pub fn add(&mut self, curve: impl Curve<Point = P> + 'static)

CurvePath.add( curve ).

Source

pub fn update_arc_lengths(&self)

CurvePath.updateArcLengths().

Source

pub fn get_curve_lengths(&self) -> Vec<f64>

CurvePath.getCurveLengths(): the running sum of the sub-curves’ lengths, cached while the curve count is unchanged.

Source

pub fn close_path(&mut self) -> &mut Self

CurvePath.closePath(): adds a line curve back to the start if the path does not already end there.

Trait Implementations§

Source§

impl Clone for Path

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 Curve for Path

Source§

type Point = Vector2

Vector2 or Vector3.
Source§

fn type_name(&self) -> &'static str

Curve.type: 'LineCurve', 'EllipseCurve', 'Path', …
Source§

fn arc_length_divisions(&self) -> usize

Curve.arcLengthDivisions, default 200.
Source§

fn get_point(&self, t: f64) -> Vector2

Curve.getPoint( t, optionalTarget ). t is an interpolation factor in [0,1].
Source§

fn get_length(&self) -> f64

Curve.getLength().
Source§

fn get_lengths(&self, divisions: usize) -> Vec<f64>

Curve.getLengths( divisions ). See the module doc: no cache.
Source§

fn get_spaced_points(&self, divisions: usize) -> Vec<Vector2>

Curve.getSpacedPoints( divisions ); returns divisions + 1 points.
Source§

fn get_points(&self, divisions: usize) -> Vec<Vector2>

Curve.getPoints( divisions ); returns divisions + 1 points.
Source§

fn curve_path_resolution(&self, divisions: usize) -> usize

How many divisions CurvePath.getPoints( divisions ) asks this curve for. three.js writes it as a chain of brand checks in CurvePath: isEllipseCurve doubles it, isLineCurve / isLineCurve3 use 1 and isSplineCurve multiplies by its point count; every other curve uses divisions as given. Here each of those subclasses overrides this.
Source§

fn is_closed_catmull_rom(&self) -> bool

extrudePath.isCatmullRomCurve3 ? extrudePath.closed : false — the one place three.js reads a subclass’ closed generically (ExtrudeGeometry). Only CatmullRomCurve3 overrides it.
Source§

fn get_point_at(&self, u: f64) -> Self::Point

Curve.getPointAt( u, optionalTarget ).
Source§

fn get_u_to_t_mapping(&self, u: f64, distance: Option<f64>) -> f64

Curve.getUtoTmapping( u, distance ), statement for statement.
Source§

fn get_tangent(&self, t: f64) -> Self::Point

Curve.getTangent( t, optionalTarget ).
Source§

fn get_tangent_at(&self, u: f64) -> Self::Point

Curve.getTangentAt( u, optionalTarget ).
Source§

fn compute_frenet_frames(&self, segments: usize, closed: bool) -> FrenetFrames

Curve.computeFrenetFrames( segments, closed ). Read more
Source§

impl Debug for Path

Source§

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

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

impl Default for Path

Source§

fn default() -> Self

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

impl Deref for Path

Source§

type Target = CurvePath<Vector2>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Path

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl !Freeze for Path

§

impl !RefUnwindSafe for Path

§

impl !Send for Path

§

impl !Sync for Path

§

impl !UnwindSafe for Path

§

impl Unpin for Path

§

impl UnsafeUnpin for Path

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.