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 asix 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: 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.