pub struct Stroke {
pub width: f32,
pub color: Color,
}Expand description
Represents the stroke properties of a shape.
The Stroke struct allows you to define the visual outline of shapes with specific width and color.
§Examples
use grafo::Color;
use grafo::Stroke;
// Create a blue stroke with a width of 1.5
let blue_stroke = Stroke::new(1.5, Color::rgb(0, 0, 255));
// Check if the stroke is empty
assert!(!blue_stroke.is_empty());
// Create a stroke with zero width
let no_stroke = Stroke::new(0.0, Color::rgb(0, 0, 0));
assert!(no_stroke.is_empty());Fields§
§width: f32The width of the stroke in pixels.
color: ColorThe color of the stroke.
Implementations§
Source§impl Stroke
impl Stroke
Sourcepub fn new(width: impl Into<f32>, color: impl Into<Color>) -> Self
pub fn new(width: impl Into<f32>, color: impl Into<Color>) -> Self
Creates a new Stroke with the specified width and color.
§Parameters
width: The width of the stroke in pixels. Must be a positive value for the stroke to be visible.color: The color of the stroke. UseColor::TRANSPARENTfor a transparent stroke.
§Examples
use grafo::Color;
use grafo::Stroke;
// Create an orange stroke with a width of 3.0
let orange_stroke = Stroke::new(3.0, Color::rgba(255, 165, 0, 255));Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Determines whether the stroke is empty.
A stroke is considered empty if its width is zero or if its color is fully transparent.
§Examples
use grafo::Color;
use grafo::Stroke;
let empty_stroke = Stroke::default();
assert!(empty_stroke.is_empty());
let visible_stroke = Stroke::new(1.0, Color::BLACK);
assert!(!visible_stroke.is_empty());Trait Implementations§
impl Copy for Stroke
impl StructuralPartialEq for Stroke
Auto Trait Implementations§
impl Freeze for Stroke
impl RefUnwindSafe for Stroke
impl Send for Stroke
impl Sync for Stroke
impl Unpin for Stroke
impl UnwindSafe for Stroke
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