Struct epaint::QuadraticBezierShape
source · [−]pub struct QuadraticBezierShape {
pub points: [Pos2; 3],
pub closed: bool,
pub fill: Color32,
pub stroke: Stroke,
}
Expand description
A quadratic Bézier Curve.
See also CubicBezierShape
.
Fields
points: [Pos2; 3]
The first point is the starting point and the last one is the ending point of the curve. The middle point is the control points.
closed: bool
fill: Color32
stroke: Stroke
Implementations
sourceimpl QuadraticBezierShape
impl QuadraticBezierShape
sourcepub fn from_points_stroke(
points: [Pos2; 3],
closed: bool,
fill: Color32,
stroke: impl Into<Stroke>
) -> Self
pub fn from_points_stroke(
points: [Pos2; 3],
closed: bool,
fill: Color32,
stroke: impl Into<Stroke>
) -> Self
Create a new quadratic Bézier shape based on the 3 points and stroke.
The first point is the starting point and the last one is the ending point of the curve. The middle point is the control points. The points should be in the order [start, control, end]
sourcepub fn transform(&self, transform: &RectTransform) -> Self
pub fn transform(&self, transform: &RectTransform) -> Self
Transform the curve with the given transform.
sourcepub fn to_path_shape(&self, tolerance: Option<f32>) -> PathShape
pub fn to_path_shape(&self, tolerance: Option<f32>) -> PathShape
Convert the quadratic Bézier curve to one PathShape
.
The tolerance
will be used to control the max distance between the curve and the base line.
sourcepub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle (includes stroke width)
sourcepub fn logical_bounding_rect(&self) -> Rect
pub fn logical_bounding_rect(&self) -> Rect
Logical bounding rectangle (ignoring stroke width)
sourcepub fn sample(&self, t: f32) -> Pos2
pub fn sample(&self, t: f32) -> Pos2
Calculate the point (x,y) at t based on the quadratic Bézier curve equation. t is in [0.0,1.0] Bézier Curve
sourcepub fn flatten(&self, tolerance: Option<f32>) -> Vec<Pos2>
pub fn flatten(&self, tolerance: Option<f32>) -> Vec<Pos2>
find a set of points that approximate the quadratic Bézier curve. the number of points is determined by the tolerance. the points may not be evenly distributed in the range [0.0,1.0] (t value)
sourcepub fn for_each_flattened_with_t<F>(&self, tolerance: f32, callback: &mut F) where
F: FnMut(Pos2, f32),
pub fn for_each_flattened_with_t<F>(&self, tolerance: f32, callback: &mut F) where
F: FnMut(Pos2, f32),
Compute a flattened approximation of the curve, invoking a callback at each step.
The callback takes the point and corresponding curve parameter at each step.
This implements the algorithm described by Raph Levien at https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html
Trait Implementations
sourceimpl Clone for QuadraticBezierShape
impl Clone for QuadraticBezierShape
sourcefn clone(&self) -> QuadraticBezierShape
fn clone(&self) -> QuadraticBezierShape
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for QuadraticBezierShape
impl Debug for QuadraticBezierShape
sourceimpl<'de> Deserialize<'de> for QuadraticBezierShape
impl<'de> Deserialize<'de> for QuadraticBezierShape
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<QuadraticBezierShape> for Shape
impl From<QuadraticBezierShape> for Shape
sourcefn from(shape: QuadraticBezierShape) -> Self
fn from(shape: QuadraticBezierShape) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<QuadraticBezierShape> for QuadraticBezierShape
impl PartialEq<QuadraticBezierShape> for QuadraticBezierShape
sourcefn eq(&self, other: &QuadraticBezierShape) -> bool
fn eq(&self, other: &QuadraticBezierShape) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl Serialize for QuadraticBezierShape
impl Serialize for QuadraticBezierShape
impl Copy for QuadraticBezierShape
impl StructuralPartialEq for QuadraticBezierShape
Auto Trait Implementations
impl RefUnwindSafe for QuadraticBezierShape
impl Send for QuadraticBezierShape
impl Sync for QuadraticBezierShape
impl Unpin for QuadraticBezierShape
impl UnwindSafe for QuadraticBezierShape
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more