pub enum Linetype {
Solid,
Dashed,
Dotted,
DashDot,
LongDash,
TwoDash,
Custom(Vec<(f64, f64)>),
}Expand description
Line type patterns.
The named variants are ggplot2’s fixed patterns; Linetype::Custom
takes a caller-supplied dash/gap sequence (#220), e.g.
Linetype::Custom(vec![(0.0, 10.0)]) together with
LineEnd::Round draws a row of round dots every 10 px (zero-length
dashes are drawn as round caps), as flow-diagram edges use.
Linetype is no longer Copy (a Custom pattern owns its Vec) —
clone it where a copy was taken before.
Variants§
Solid
Dashed
Dotted
DashDot
LongDash
TwoDash
Custom(Vec<(f64, f64)>)
Arbitrary (dash, gap) pairs in px, rendered through the same
stroke-dasharray / dashed-stroking path as the named variants.
Degenerate input never panics: pairs with a non-finite value are
dropped, negative lengths are clamped to 0, and a pattern with no
usable pairs (empty, all-NaN, or a cycle of zero total length) draws
solid. See Linetype::dash_pattern.
Implementations§
Source§impl Linetype
impl Linetype
Sourcepub const ALL: &[Linetype]
pub const ALL: &[Linetype]
All named linetypes in order (for discrete scale mapping).
Linetype::Custom is not part of the cycle.
Sourcepub fn pattern(&self) -> &[(f64, f64)]
pub fn pattern(&self) -> &[(f64, f64)]
Get the dash pattern as (draw_len, gap_len) pairs in pixels, exactly
as stored. For Linetype::Custom this is the caller’s raw input;
renderers use the sanitised Linetype::dash_pattern instead.
Sourcepub fn dash_pattern(&self) -> Vec<(f64, f64)>
pub fn dash_pattern(&self) -> Vec<(f64, f64)>
The dash pattern a renderer should draw: Linetype::pattern with
non-finite pairs dropped and negative lengths clamped to 0. Returns
an empty vector (solid) when nothing usable is left or one full
dash+gap cycle is shorter than 0.01 px (or overflows to infinity), so no backend ever sees a
NaN, a negative length, or a zero-length cycle (which would never
advance a dashed stroker).
Trait Implementations§
impl StructuralPartialEq for Linetype
Auto Trait Implementations§
impl Freeze for Linetype
impl RefUnwindSafe for Linetype
impl Send for Linetype
impl Sync for Linetype
impl Unpin for Linetype
impl UnsafeUnpin for Linetype
impl UnwindSafe for Linetype
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more