Struct piet::StrokeStyle[][src]

pub struct StrokeStyle {
    pub line_join: LineJoin,
    pub line_cap: LineCap,
    pub dash_pattern: StrokeDash,
    pub dash_offset: f64,
}
Expand description

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

How to terminate open paths.

(closed paths do not have ends.)

by default, this is LineCap::Butt.

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

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);

Builder-style method to set the LineJoin.

Builder-style method to set the LineCap.

Builder-style method to set the dash_offset.

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.

Set the LineJoin.

Set the LineCap.

Set the dash offset.

Set the dash pattern.

This method always allocates. To construct without allocating, use the dash_pattern builder method.

If the current LineJoin is LineJoin::Miter return the miter limit.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.