pub struct DashPattern {
pub on: f64,
pub off: f64,
pub phase: f64,
}Expand description
The per-corner radii and dash-pattern vocabulary PaintScene’s own
signatures name, re-exported from frust-scene so a widget calling
PaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/
PaintScene::stroke_path_dashed can name their arguments through the same
paint surface it already paints through (mirrors the crate-root accesskit
re-export).
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 more