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§
Source§impl ShapeStyle
impl ShapeStyle
Sourcepub fn filled(&self) -> Self
pub fn filled(&self) -> Self
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:
Sourcepub fn stroke_width(&self, width: u32) -> Self
pub fn stroke_width(&self, width: u32) -> Self
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§
Source§impl BackendStyle for ShapeStyle
impl BackendStyle for ShapeStyle
Source§fn color(&self) -> BackendColor
fn color(&self) -> BackendColor
Returns the color as interpreted by the backend.
Source§fn stroke_width(&self) -> u32
fn stroke_width(&self) -> u32
Returns the stroke width.
Source§impl Clone for ShapeStyle
impl Clone for ShapeStyle
Source§fn clone(&self) -> ShapeStyle
fn clone(&self) -> ShapeStyle
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ShapeStyle
impl Debug for ShapeStyle
Source§impl<T: Color> From<T> for ShapeStyle
impl<T: Color> From<T> for ShapeStyle
Source§impl PartialEq for ShapeStyle
impl PartialEq for ShapeStyle
impl Copy for ShapeStyle
impl StructuralPartialEq for ShapeStyle
Auto Trait Implementations§
impl Freeze for ShapeStyle
impl RefUnwindSafe for ShapeStyle
impl Send for ShapeStyle
impl Sync for ShapeStyle
impl Unpin for ShapeStyle
impl UnwindSafe for ShapeStyle
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes