pub struct DashPattern {
pub on: f64,
pub off: f64,
pub phase: f64,
}Expand description
A stroke’s dash pattern: an on run, an off gap, and a phase offset
into that repeating cycle — all lengths in the pre-transform coordinate
space.
One on/off pair rather than an arbitrary-length array: it covers the dashed
dividers/outlines/focus rings widgets ask for, stays Copy (so
PathStyle and every command holding one stay Copy/allocation-free),
and the render crate expands it into a [on, off] slice at encode time.
Fields§
§on: f64Length of each painted dash.
off: f64Length of each gap between dashes.
phase: f64Distance into the on/off cycle the pattern starts at — animate this to march the dashes along the path.
Implementations§
Source§impl DashPattern
impl DashPattern
Sourcepub const fn new(on: f64, off: f64) -> DashPattern
pub const fn new(on: f64, off: f64) -> DashPattern
An on/off cycle starting at phase 0.
Sourcepub const fn with_phase(self, phase: f64) -> DashPattern
pub const fn with_phase(self, phase: f64) -> DashPattern
The same pattern offset by phase into its cycle.
Sourcepub fn is_effective(&self) -> bool
pub fn is_effective(&self) -> bool
Whether this pattern actually breaks a stroke into dashes.
A non-positive or non-finite length has no dashed interpretation (a zero
off is a solid line; a zero on paints nothing, which a caller never
means by “dashed”), so frust-render strokes such a path solid rather
than feeding a degenerate cycle to the dash iterator. Additionally, a
period (on + off) smaller than [DASH_PERIOD_EPSILON] is too dense to
efficiently expand at encode time and is visually indistinguishable from
a solid stroke anyway, so the pattern falls back to solid.
Trait Implementations§
Source§impl Clone for DashPattern
impl Clone for DashPattern
Source§fn clone(&self) -> DashPattern
fn clone(&self) -> DashPattern
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DashPattern
Source§impl Debug for DashPattern
impl Debug for DashPattern
Source§impl PartialEq for DashPattern
impl PartialEq for DashPattern
impl StructuralPartialEq for DashPattern
Auto Trait Implementations§
impl Freeze for DashPattern
impl RefUnwindSafe for DashPattern
impl Send for DashPattern
impl Sync for DashPattern
impl Unpin for DashPattern
impl UnsafeUnpin for DashPattern
impl UnwindSafe for DashPattern
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.