Struct lyon_geom::CubicBezierSegment [−][src]
pub struct CubicBezierSegment<S> { pub from: Point<S>, pub ctrl1: Point<S>, pub ctrl2: Point<S>, pub to: Point<S>, }
Expand description
A 2d curve segment defined by four points: the beginning of the segment, two control points and the end of the segment.
The curve is defined by equation:²
∀ t ∈ [0..1], P(t) = (1 - t)³ * from + 3 * (1 - t)² * t * ctrl1 + 3 * t² * (1 - t) * ctrl2 + t³ * to
Fields
from: Point<S>
ctrl1: Point<S>
ctrl2: Point<S>
to: Point<S>
Implementations
Sample the x coordinate of the curve at t (expecting t between 0 and 1).
Sample the y coordinate of the curve at t (expecting t between 0 and 1).
Return the parameter values corresponding to a given x coordinate. See also solve_t_for_x for monotonic curves.
Return the parameter values corresponding to a given y coordinate. See also solve_t_for_y for monotonic curves.
Sample the curve’s derivative at t (expecting t between 0 and 1).
Sample the x coordinate of the curve’s derivative at t (expecting t between 0 and 1).
Sample the y coordinate of the curve’s derivative at t (expecting t between 0 and 1).
Return the sub-curve inside a given range of t.
This is equivalent to splitting at the range’s end points.
Split this curve into two sub-curves.
Return the curve before the split point.
Return the curve after the split point.
Computes a “fat line” of this segment.
A fat line is two conservative lines between which the segment is fully contained.
Applies the transform to this curve and returns the results.
Returns the flattened representation of the curve as an iterator, starting after the current point.
Invokes a callback between each monotonic part of the segment.
Invokes a callback for each monotonic part of the segment..
pub fn for_each_quadratic_bezier<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&QuadraticBezierSegment<S>),
pub fn for_each_quadratic_bezier<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&QuadraticBezierSegment<S>),
Approximates the cubic bézier curve with sequence of quadratic ones, invoking a callback at each step.
pub fn for_each_quadratic_bezier_with_t<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&QuadraticBezierSegment<S>, Range<S>),
pub fn for_each_quadratic_bezier_with_t<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&QuadraticBezierSegment<S>, Range<S>),
Approximates the cubic bézier curve with sequence of quadratic ones, invoking a callback at each step.
pub fn for_each_monotonic_quadratic<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&Monotonic<QuadraticBezierSegment<S>>),
pub fn for_each_monotonic_quadratic<F>(&self, tolerance: S, cb: &mut F) where
F: FnMut(&Monotonic<QuadraticBezierSegment<S>>),
Approximates the cubic bézier curve with sequence of monotonic quadratic ones, invoking a callback at each step.
Iterates through the curve invoking a callback at each point.
pub fn for_each_flattened_with_t<F: FnMut(Point<S>, S)>(
&self,
tolerance: S,
callback: &mut F
)
pub fn for_each_flattened_with_t<F: FnMut(Point<S>, S)>(
&self,
tolerance: S,
callback: &mut F
)
Iterates through the curve invoking a callback at each point.
Compute the length of the segment using a flattened approximation.
Return local x extrema or None if this curve is monotonic.
This returns the advancements along the curve, not the actual x position.
Return local y extrema or None if this curve is monotonic.
This returns the advancements along the curve, not the actual y position.
Find the advancement of the y-most position in the curve.
This returns the advancement along the curve, not the actual y position.
Find the advancement of the y-least position in the curve.
This returns the advancement along the curve, not the actual y position.
Find the advancement of the x-most position in the curve.
This returns the advancement along the curve, not the actual x position.
Find the x-least position in the curve.
Returns a conservative rectangle the curve is contained in.
This method is faster than bounding_rect
but more conservative.
Returns a conservative range of x this curve is contained in.
Returns a conservative range of y this curve is contained in.
Returns the smallest rectangle the curve is contained in
Returns the smallest range of x this curve is contained in.
Returns the smallest range of y this curve is contained in.
Cast this curve into a monotonic curve without checking that the monotonicity assumption is correct.
Returns whether this segment is monotonic on the x axis.
Returns whether this segment is monotonic on the y axis.
Returns whether this segment is fully monotonic.
Computes the intersections (if any) between this segment and another one.
The result is provided in the form of the t
parameters of each point along the curves. To
get the intersection points, sample the curves at the corresponding values.
Returns endpoint intersections where an endpoint intersects the interior of the other curve, but not endpoint/endpoint intersections.
Returns no intersections if either curve is a point.
Computes the intersection points (if any) between this segment and another one.
pub fn quadratic_intersections_t(
&self,
curve: &QuadraticBezierSegment<S>
) -> ArrayVec<[(S, S); 9]>
pub fn quadratic_intersections_t(
&self,
curve: &QuadraticBezierSegment<S>
) -> ArrayVec<[(S, S); 9]>
Computes the intersections (if any) between this segment a quadratic bézier segment.
The result is provided in the form of the t
parameters of each point along the curves. To
get the intersection points, sample the curves at the corresponding values.
Returns endpoint intersections where an endpoint intersects the interior of the other curve, but not endpoint/endpoint intersections.
Returns no intersections if either curve is a point.
pub fn quadratic_intersections(
&self,
curve: &QuadraticBezierSegment<S>
) -> ArrayVec<[Point<S>; 9]>
pub fn quadratic_intersections(
&self,
curve: &QuadraticBezierSegment<S>
) -> ArrayVec<[Point<S>; 9]>
Computes the intersection points (if any) between this segment and a quadratic bézier segment.
Computes the intersections (if any) between this segment and a line.
The result is provided in the form of the t
parameters of each
point along curve. To get the intersection points, sample the curve
at the corresponding values.
Computes the intersection points (if any) between this segment and a line.
Computes the intersections (if any) between this segment and a line segment.
The result is provided in the form of the t
parameters of each
point along curve and segment. To get the intersection points, sample
the segments at the corresponding values.
Trait Implementations
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<S> RefUnwindSafe for CubicBezierSegment<S> where
S: RefUnwindSafe,
impl<S> Send for CubicBezierSegment<S> where
S: Send,
impl<S> Sync for CubicBezierSegment<S> where
S: Sync,
impl<S> Unpin for CubicBezierSegment<S> where
S: Unpin,
impl<S> UnwindSafe for CubicBezierSegment<S> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more