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) -> Self
pub fn from_rect(rect: Rect) -> Self
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) -> Self
pub fn from_affine(affine: Affine) -> Self
Create an ellipse from an affine transformation of the unit circle.
sourcepub fn with_center(self, new_center: Point) -> Ellipse
pub fn with_center(self, new_center: 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.
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§type PathElementsIter<'iter> = Chain<Once<PathEl>, ArcAppendIter>
type PathElementsIter<'iter> = Chain<Once<PathEl>, ArcAppendIter>
path_elements
method.source§fn path_elements(&self, tolerance: f64) -> Self::PathElementsIter<'_>
fn path_elements(&self, tolerance: f64) -> Self::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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)