pub struct Ellipse { /* private fields */ }Expand description
An ellipse.
Implementations§
Source§impl Ellipse
impl Ellipse
Sourcepub fn new(
center: impl Into<Point>,
radii: impl Into<Vec2>,
x_rotation: f64,
) -> Ellipse
pub fn new( center: impl Into<Point>, radii: impl Into<Vec2>, x_rotation: f64, ) -> Ellipse
Create A new ellipse with a given center, radii, and rotation.
The returned ellipse will be the result of taking a circle, stretching
it by the radii along the x and y axes, then rotating it from the
x axis by rotation radians, before finally translating the center
to center.
Rotation is clockwise in a y-down coordinate system. For more on
rotation, see Affine::rotate.
Sourcepub fn from_rect(rect: Rect) -> Ellipse
pub fn from_rect(rect: Rect) -> Ellipse
Returns the largest ellipse that can be bounded by this Rect.
This uses the absolute width and height of the rectangle.
This ellipse is always axis-aligned; to apply rotation you can call
with_rotation with the result.
Sourcepub fn from_affine(affine: Affine) -> Ellipse
pub fn from_affine(affine: Affine) -> Ellipse
Create an ellipse from an affine transformation of the unit circle.
Sourcepub fn with_center(self, new_center: impl Into<Point>) -> Ellipse
pub fn with_center(self, new_center: impl Into<Point>) -> Ellipse
Create a new Ellipse centered on the provided point.
Sourcepub fn with_radii(self, new_radii: Vec2) -> Ellipse
pub fn with_radii(self, new_radii: Vec2) -> Ellipse
Create a new Ellipse with the provided radii.
Sourcepub fn with_rotation(self, rotation: f64) -> Ellipse
pub fn with_rotation(self, rotation: f64) -> Ellipse
Create a new Ellipse, with the rotation replaced by rotation
radians.
The rotation is clockwise, for a y-down coordinate system. For more
on rotation, See Affine::rotate.
Sourcepub fn radii(&self) -> Vec2
pub fn radii(&self) -> Vec2
Returns the two radii of this ellipse.
The first number is the horizontal radius and the second is the vertical radius, before rotation.
If you are only interested in the value of the greatest or smallest radius of this ellipse,
consider using Ellipse::major_radius or Ellipse::minor_radius instead.
Sourcepub fn major_radius(&self) -> f64
pub fn major_radius(&self) -> f64
Returns the major radius of this ellipse.
This metric is also known as the semi-major axis.
Sourcepub fn minor_radius(&self) -> f64
pub fn minor_radius(&self) -> f64
Returns the minor radius of this ellipse.
This metric is also known as the semi-minor axis.
Sourcepub fn rotation(&self) -> f64
pub fn rotation(&self) -> f64
The ellipse’s rotation, in radians.
This allows all possible ellipses to be drawn by always starting with an ellipse with the two radii on the x and y axes.
Sourcepub fn radii_and_rotation(&self) -> (Vec2, f64)
pub fn radii_and_rotation(&self) -> (Vec2, f64)
Returns the radii and the rotation of this ellipse.
Equivalent to (self.radii(), self.rotation()) but more efficient.
Trait Implementations§
Source§impl Shape for Ellipse
impl Shape for Ellipse
Source§fn perimeter(&self, accuracy: f64) -> f64
fn perimeter(&self, accuracy: f64) -> f64
Approximate the ellipse perimeter.
This uses a numerical approximation. The absolute error between the calculated perimeter
and the true perimeter is bounded by accuracy (modulo floating point rounding errors).
For circular ellipses (equal horizontal and vertical radii), the calculated perimeter is exact.
Source§type PathElementsIter<'iter> = Chain<Once<PathEl>, ArcAppendIter>
type PathElementsIter<'iter> = Chain<Once<PathEl>, ArcAppendIter>
path_elements method.Source§fn path_elements(
&self,
tolerance: f64,
) -> <Ellipse as Shape>::PathElementsIter<'_>
fn path_elements( &self, tolerance: f64, ) -> <Ellipse as Shape>::PathElementsIter<'_>
Source§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
Source§fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
Source§fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
Source§fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
impl Copy for Ellipse
impl StructuralPartialEq for Ellipse
Auto Trait Implementations§
impl Freeze for Ellipse
impl RefUnwindSafe for Ellipse
impl Send for Ellipse
impl Sync for Ellipse
impl Unpin for Ellipse
impl UnwindSafe for Ellipse
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.