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’sStrokeCap; - filled annular sector —
inner/outeras 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: f32Normalized to [0, TAU).
sweep_angle: f32Normalized to [0, TAU].
cap: StrokeCapImplementations§
Source§impl ArcGeometry
impl ArcGeometry
Sourcepub fn new(
center: Point,
inner_radius: f32,
outer_radius: f32,
start_angle: f32,
sweep_angle: f32,
cap: StrokeCap,
) -> Self
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.
Sourcepub fn mid_radius(&self) -> f32
pub fn mid_radius(&self) -> f32
Radius of the band’s centerline (ra in the analytic arc SDF).
Sourcepub fn half_thickness(&self) -> f32
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.
Sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
True when the band encloses no area and therefore must not be emitted.
Sourcepub fn contains_angle(&self, angle: f32) -> bool
pub fn contains_angle(&self, angle: f32) -> bool
True when angle lies inside [start, start + sweep] (mod TAU).
Sourcepub fn scaled_about(&self, center: Point, scale: f32) -> Self
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.
Sourcepub fn bounds(&self) -> Rect
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
impl Clone for ArcGeometry
Source§fn clone(&self) -> ArcGeometry
fn clone(&self) -> ArcGeometry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more