pub struct QuadraticBezierShape {
pub points: [Pos2; 3],
pub closed: bool,
pub fill: Color32,
pub stroke: PathStroke,
}
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: PathStroke
Implementations§
§impl QuadraticBezierShape
impl QuadraticBezierShape
pub fn from_points_stroke(
points: [Pos2; 3],
closed: bool,
fill: Color32,
stroke: impl Into<PathStroke>
) -> QuadraticBezierShape
pub fn from_points_stroke( points: [Pos2; 3], closed: bool, fill: Color32, stroke: impl Into<PathStroke> ) -> QuadraticBezierShape
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]
pub fn transform(&self, transform: &RectTransform) -> QuadraticBezierShape
pub fn transform(&self, transform: &RectTransform) -> QuadraticBezierShape
Transform the curve with the given transform.
pub 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.
pub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle (includes stroke width)
pub fn logical_bounding_rect(&self) -> Rect
pub fn logical_bounding_rect(&self) -> Rect
Logical bounding rectangle (ignoring stroke width)
pub 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
pub 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)
pub fn for_each_flattened_with_t<F>(&self, tolerance: f32, callback: &mut F)
pub fn for_each_flattened_with_t<F>(&self, tolerance: f32, callback: &mut F)
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§
§impl Clone for QuadraticBezierShape
impl Clone for QuadraticBezierShape
§fn clone(&self) -> QuadraticBezierShape
fn clone(&self) -> QuadraticBezierShape
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for QuadraticBezierShape
impl Debug for QuadraticBezierShape
§impl<'de> Deserialize<'de> for QuadraticBezierShape
impl<'de> Deserialize<'de> for QuadraticBezierShape
§fn deserialize<__D>(
__deserializer: __D
) -> Result<QuadraticBezierShape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<QuadraticBezierShape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl From<QuadraticBezierShape> for Shape
impl From<QuadraticBezierShape> for Shape
§fn from(shape: QuadraticBezierShape) -> Shape
fn from(shape: QuadraticBezierShape) -> Shape
§impl PartialEq for QuadraticBezierShape
impl PartialEq for QuadraticBezierShape
§fn eq(&self, other: &QuadraticBezierShape) -> bool
fn eq(&self, other: &QuadraticBezierShape) -> bool
self
and other
values to be equal, and is used
by ==
.§impl Serialize for QuadraticBezierShape
impl Serialize for QuadraticBezierShape
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for QuadraticBezierShape
Auto Trait Implementations§
impl Freeze for QuadraticBezierShape
impl !RefUnwindSafe for QuadraticBezierShape
impl Send for QuadraticBezierShape
impl Sync for QuadraticBezierShape
impl Unpin for QuadraticBezierShape
impl !UnwindSafe for QuadraticBezierShape
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request