Struct piet_common::StrokeStyle [−][src]
Options for drawing stroked lines.
You may configure particular aspects of the style by using the methods described below.
Defaults
Currently, the style (and its various consituent parts) have Default
impls that conform to the defaults described in the
Postscript Language Manual, 3rd Edition; that document is the
basis for the choice of these types, and can be consulted for detailed
explanations and illustrations.
It is possible that in the future certain of these defaults may change; if you are particular about your style you can create the various types explicitly instead of relying on the default impls.
use piet::{LineJoin, StrokeStyle}; const CONST_STLYE: StrokeStyle = StrokeStyle::new() .dash_pattern(&[5.0, 1.0, 2.0]) .line_join(LineJoin::Round); let style = StrokeStyle::new() .dash_pattern(&[10.0, 5.0, 2.0]) .dash_offset(5.0);
Fields
line_join: LineJoin
How to join segments of the path.
By default, this is LineJoin::Miter
with a limit
of 10.0
.
line_cap: LineCap
dash_pattern: StrokeDash
The sequence of alternating dashes and gaps uses to draw the line.
If the sequence is not empty, all numbers should be finite and non-negative, and the sequence should not be all zeros.
On platforms that do not support an odd number of lengths in the array, the implementation may concatenate two copies of the array to reach an even count.
By default, this is empty (&[]
), indicating a solid line.
dash_offset: f64
The distance into the dash_pattern
at which drawing begins.
By default, this is 0.0
.
Implementations
impl StrokeStyle
[src]
pub const fn new() -> StrokeStyle
[src]
Create a new StrokeStyle
with the provided pattern.
For no pattern (a solid line) pass &[]
.
This is available in a const
context and does not allocate;
the other methods for setting the dash pattern do allocate, for
annoying reasons.
Example
use piet::{LineJoin, StrokeStyle}; const STYLE: StrokeStyle = StrokeStyle::new() .dash_pattern(&[4.0, 2.0]) .dash_offset(8.0) .line_join(LineJoin::Round);
pub const fn line_join(self, line_join: LineJoin) -> StrokeStyle
[src]
Builder-style method to set the LineJoin
.
pub const fn line_cap(self, line_cap: LineCap) -> StrokeStyle
[src]
Builder-style method to set the LineCap
.
pub const fn dash_offset(self, offset: f64) -> StrokeStyle
[src]
Builder-style method to set the dash_offset
.
pub const fn dash_pattern(self, lengths: &'static [f64]) -> StrokeStyle
[src]
Builder-style method to set the dash_pattern
.
This method takes a &'static [f64]
, and does not allocate. If you
do not have a static slice, you may use set_dash_pattern
instead,
which does allocate.
pub fn set_line_join(&mut self, line_join: LineJoin)
[src]
Set the LineJoin
.
pub fn set_line_cap(&mut self, line_cap: LineCap)
[src]
Set the LineCap
.
pub fn set_dash_offset(&mut self, offset: f64)
[src]
Set the dash offset.
pub fn set_dash_pattern(&mut self, lengths: impl Into<Rc<[f64]>>)
[src]
Set the dash pattern.
This method always allocates. To construct without allocating, use the
dash_pattern
builder method.
pub fn miter_limit(&self) -> Option<f64>
[src]
If the current LineJoin
is LineJoin::Miter
return the miter limit.
Trait Implementations
impl Clone for StrokeStyle
[src]
pub fn clone(&self) -> StrokeStyle
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for StrokeStyle
[src]
impl Default for StrokeStyle
[src]
pub fn default() -> StrokeStyle
[src]
impl PartialEq<StrokeStyle> for StrokeStyle
[src]
pub fn eq(&self, other: &StrokeStyle) -> bool
[src]
pub fn ne(&self, other: &StrokeStyle) -> bool
[src]
impl StructuralPartialEq for StrokeStyle
[src]
Auto Trait Implementations
impl !RefUnwindSafe for StrokeStyle
impl !Send for StrokeStyle
impl !Sync for StrokeStyle
impl Unpin for StrokeStyle
impl UnwindSafe for StrokeStyle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
[src]
pub fn round_from(x: T) -> T
[src]
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
[src]
U: RoundFrom<T>,
pub fn round_into(self) -> U
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,