pub struct Ellipse<T = i32>(/* private fields */);
Expand description
An Ellipse
positioned at (x, y)
, with width
and height
. A circle is an Ellipse
where
width
and height
are equal.
Please see the module-level documentation for examples.
Implementations§
Source§impl<T: Copy> Ellipse<T>
impl<T: Copy> Ellipse<T>
Sourcepub fn coords(&self) -> [T; 4]
pub fn coords(&self) -> [T; 4]
Returns Ellipse
values as [x, y, width, height]
.
§Example
let e = ellipse!(5, 10, 100, 100);
assert_eq!(e.coords(), [5, 10, 100, 100]);
Sourcepub fn coords_mut(&mut self) -> &mut [T; 4]
pub fn coords_mut(&mut self) -> &mut [T; 4]
Returns Ellipse
values as a mutable slice &[x, y, width, height]
.
§Example
let mut e = ellipse!(5, 10, 100, 100);
for v in e.coords_mut() {
*v += 5;
}
assert_eq!(e.coords(), [10, 15, 105, 105]);
Sourcepub fn set_height(&mut self, height: T)
pub fn set_height(&mut self, height: T)
Sets the height
of the ellipse.
Source§impl<T: Num> Ellipse<T>
impl<T: Num> Ellipse<T>
Sourcepub fn circle(x: T, y: T, radius: T) -> Self
pub fn circle(x: T, y: T, radius: T) -> Self
Constructs a circle Ellipse
at position (x, y)
with radius
.
Sourcepub fn with_position<P: Into<Point<T>>>(p: P, width: T, height: T) -> Self
pub fn with_position<P: Into<Point<T>>>(p: P, width: T, height: T) -> Self
Constructs an Ellipse
at position Point with width
and height
.
Sourcepub fn circle_with_position<P: Into<Point<T>>>(p: P, radius: T) -> Self
pub fn circle_with_position<P: Into<Point<T>>>(p: P, radius: T) -> Self
Constructs a circle Ellipse
at position Point with radius
.
Sourcepub fn from_center<P: Into<Point<T>>>(p: P, width: T, height: T) -> Self
pub fn from_center<P: Into<Point<T>>>(p: P, width: T, height: T) -> Self
Constructs an Ellipse
centered at position (x, y)
with width
and height
.
§Example
let e = Ellipse::from_center([50, 50], 100, 100);
assert_eq!(e.coords(), [0, 0, 100, 100]);
Sourcepub fn circle_from_center<P: Into<Point<T>>>(p: P, radius: T) -> Self
pub fn circle_from_center<P: Into<Point<T>>>(p: P, radius: T) -> Self
Constructs a circle Ellipse
centered at position (x, y)
with radius
.
§Example
let c = Ellipse::circle_from_center([50, 50], 100);
assert_eq!(c.coords(), [0, 0, 200, 200]);
Sourcepub fn set_radius(&mut self, radius: T)
pub fn set_radius(&mut self, radius: T)
Sets the radius
of the circle.
Sourcepub fn offset<P>(&mut self, offsets: P)
pub fn offset<P>(&mut self, offsets: P)
Offsets an ellipse by shifting coordinates by given amount.
Sourcepub fn offset_x(&mut self, offset: T)
pub fn offset_x(&mut self, offset: T)
Offsets the x-coordinate
of the ellipse by a given amount.
Sourcepub fn offset_y(&mut self, offset: T)
pub fn offset_y(&mut self, offset: T)
Offsets the y-coordinate
of the ellipse by a given amount.
Sourcepub fn offset_width(&mut self, offset: T)
pub fn offset_width(&mut self, offset: T)
Offsets the width
of the ellipse by a given amount.
Sourcepub fn offset_height(&mut self, offset: T)
pub fn offset_height(&mut self, offset: T)
Offsets the height
of the ellipse by a given amount.
Sourcepub fn offset_radius(&mut self, offset: T)
pub fn offset_radius(&mut self, offset: T)
Offsets the radius
of the circle by a given amount.
Sourcepub fn bounding_rect(&self) -> Rect<T>
pub fn bounding_rect(&self) -> Rect<T>
Returns the bounding Rect of the ellipse.
Sourcepub fn set_bottom(&mut self, bottom: T)
pub fn set_bottom(&mut self, bottom: T)
Set the vertical position of the bottom edge.
Sourcepub fn bottom_left(&self) -> Point<T>
pub fn bottom_left(&self) -> Point<T>
Returns the bottom-left position as Point.
Sourcepub fn bottom_right(&self) -> Point<T>
pub fn bottom_right(&self) -> Point<T>
Returns the bottom-right position as Point.
Source§impl<T> Ellipse<T>
impl<T> Ellipse<T>
Sourcepub fn as_<U>(&self) -> Ellipse<U>where
U: 'static + Copy,
T: AsPrimitive<U>,
pub fn as_<U>(&self) -> Ellipse<U>where
U: 'static + Copy,
T: AsPrimitive<U>,
Converts Ellipse < T > to Ellipse < U >.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Ellipse<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Ellipse<T>where
T: Deserialize<'de>,
Source§fn 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>,
Source§impl<T: Default> FromIterator<T> for Ellipse<T>
impl<T: Default> FromIterator<T> for Ellipse<T>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
Source§impl<'a, T> IntoIterator for &'a Ellipse<T>
impl<'a, T> IntoIterator for &'a Ellipse<T>
Source§impl<'a, T> IntoIterator for &'a mut Ellipse<T>
impl<'a, T> IntoIterator for &'a mut Ellipse<T>
Source§impl<T> IntoIterator for Ellipse<T>
impl<T> IntoIterator for Ellipse<T>
impl<T: Copy> Copy for Ellipse<T>
impl<T: Eq> Eq for Ellipse<T>
impl<T> StructuralPartialEq for Ellipse<T>
Auto Trait Implementations§
impl<T> Freeze for Ellipse<T>where
T: Freeze,
impl<T> RefUnwindSafe for Ellipse<T>where
T: RefUnwindSafe,
impl<T> Send for Ellipse<T>where
T: Send,
impl<T> Sync for Ellipse<T>where
T: Sync,
impl<T> Unpin for Ellipse<T>where
T: Unpin,
impl<T> UnwindSafe for Ellipse<T>where
T: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.