Skip to main content

ArcGeometry

Struct ArcGeometry 

Source
pub struct ArcGeometry {
    pub center: Point,
    pub inner_radius: f32,
    pub outer_radius: f32,
    pub start_angle: f32,
    pub sweep_angle: f32,
    pub cap: StrokeCap,
}
Expand description

A resolved circular band between two radii, limited to an angular sweep.

Both a stroked arc and a filled annular sector lower to this single form:

  • stroked arc — inner = radius - width/2, outer = radius + width/2, ends shaped by the stroke’s StrokeCap;
  • filled annular sector — inner/outer as given, always butt (flat radial) ends.

Values are normalized on construction: sweep_angle is non-negative and at most TAU, outer_radius >= inner_radius >= 0, and non-finite inputs collapse to a degenerate geometry (see ArcGeometry::is_degenerate).

Fields§

§center: Point§inner_radius: f32§outer_radius: f32§start_angle: f32

Normalized to [0, TAU).

§sweep_angle: f32

Normalized to [0, TAU].

§cap: StrokeCap

Implementations§

Source§

impl ArcGeometry

Source

pub fn new( center: Point, inner_radius: f32, outer_radius: f32, start_angle: f32, sweep_angle: f32, cap: StrokeCap, ) -> Self

Normalizing constructor. Never panics and never stores a NaN.

Source

pub fn mid_radius(&self) -> f32

Radius of the band’s centerline (ra in the analytic arc SDF).

Source

pub fn half_thickness(&self) -> f32

Half the band thickness (rb in the analytic arc SDF). Also the radius of a round cap and the projection distance of a square cap.

Source

pub fn is_degenerate(&self) -> bool

True when the band encloses no area and therefore must not be emitted.

Source

pub fn contains_angle(&self, angle: f32) -> bool

True when angle lies inside [start, start + sweep] (mod TAU).

Source

pub fn scaled_about(&self, center: Point, scale: f32) -> Self

Scales radii and translates the center. Angles are unchanged, so this is only valid for a uniform (non-mirroring) scale.

Source

pub fn bounds(&self) -> Rect

Tight axis-aligned bounding box of the rendered band, caps included.

The box is the union of

  • the two radial ends (inner and outer radius, extended for round/square caps), and
  • the outer-radius point at every axis direction (0, 90, 180, 270 degrees) that the sweep actually crosses.

Sampling only the endpoints would be wrong for any sweep that crosses an axis: a 0..270 degree sweep reaches center.x + outer and center.x - outer even though neither endpoint does.

Trait Implementations§

Source§

impl Clone for ArcGeometry

Source§

fn clone(&self) -> ArcGeometry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ArcGeometry

Source§

impl Debug for ArcGeometry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ArcGeometry

Source§

fn eq(&self, other: &ArcGeometry) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArcGeometry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.