pub struct ShapeStyle {
    pub color: RGBAColor,
    pub filled: bool,
    pub stroke_width: u32,
}
Expand description

Style for any shape

Fields

color: RGBAColor

Specification of the color.

filled: bool

Whether the style is filled with color.

stroke_width: u32

Stroke width.

Implementations

Returns a filled style with the same color and stroke width.

Example
use plotters::prelude::*;
let original_style = ShapeStyle {
    color: BLUE.mix(0.6),
    filled: false,
    stroke_width: 2,
};
let filled_style = original_style.filled();
let drawing_area = SVGBackend::new("shape_style_filled.svg", (400, 200)).into_drawing_area();
drawing_area.fill(&WHITE).unwrap();
drawing_area.draw(&Circle::new((150, 100), 90, original_style));
drawing_area.draw(&Circle::new((250, 100), 90, filled_style));

The result is a figure with two circles, one of them filled:

Returns a new style with the same color and the specified stroke width.

Example
use plotters::prelude::*;
let original_style = ShapeStyle {
    color: BLUE.mix(0.6),
    filled: false,
    stroke_width: 2,
};
let new_style = original_style.stroke_width(5);
let drawing_area = SVGBackend::new("shape_style_stroke_width.svg", (400, 200)).into_drawing_area();
drawing_area.fill(&WHITE).unwrap();
drawing_area.draw(&Circle::new((150, 100), 90, original_style));
drawing_area.draw(&Circle::new((250, 100), 90, new_style));

The result is a figure with two circles, one of them thicker than the other:

Trait Implementations

Returns the color as interpreted by the backend.

Returns the stroke width.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Converts to this type from the input type.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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.