pub struct Line<F: IntoFill> {
pub color: F::Fill,
pub mode: Option<OverlayMode>,
pub thickness: u32,
pub start: (u32, u32),
pub end: (u32, u32),
pub antialiased: bool,
pub rounded: bool,
pub position: BorderPosition,
}Expand description
A line.
At its core, this method utilizes Bresenham’s line algorithm, and Xiaolin Wu’s line algorithm for antialiased lines. Thicker lines are drawn as polygons.
Fields§
§color: F::FillThe color of the line.
mode: Option<OverlayMode>The overlay mode of the line, or None to inherit from the overlay mode of the image.
thickness: u32The thickness of the line, in pixels. Defaults to 1.
start: (u32, u32)The start point of the line.
end: (u32, u32)The end point of the line.
antialiased: boolWhether the line should be antialiased. Note that drawing antialiased lines is slower than
drawing non-antialiased lines. Defaults to false.
rounded: boolWhether the endpoints of the line should be “rounded off” with circles. Defaults to false.
Currently, endpoints are not antialiased, regardless of the value of antialiased.
Note that for even-numbered thicknesses, the endpoints will not be perfectly aligned with the line. For optimal results, use odd-numbered thicknesses when using enabling this field.
position: BorderPositionThe position of the line relative to the start and end points. Defaults to Center
(which is different from the default of Border).
Implementations§
Source§impl<F: IntoFill> Line<F>
impl<F: IntoFill> Line<F>
Sourcepub fn with_color(self, color: F) -> Self
pub fn with_color(self, color: F) -> Self
Sets the color of the line.
Sourcepub const fn with_mode(self, mode: OverlayMode) -> Self
pub const fn with_mode(self, mode: OverlayMode) -> Self
Sets the overlay mode of the line.
Sourcepub const fn with_thickness(self, thickness: u32) -> Self
pub const fn with_thickness(self, thickness: u32) -> Self
Sets the thickness of the line.
Sourcepub fn with_start(self, x: u32, y: u32) -> Self
pub fn with_start(self, x: u32, y: u32) -> Self
Sets the start coordinates of the line.
Sourcepub const fn with_antialiased(self, antialiased: bool) -> Self
pub const fn with_antialiased(self, antialiased: bool) -> Self
Sets whether the line should be antialiased. If this is set to true, the overlay
mode of this line will also be set to OverlayMode::Merge.
Sourcepub const fn with_rounded(self, rounded: bool) -> Self
pub const fn with_rounded(self, rounded: bool) -> Self
Sets whether the line should be rounded.
Sourcepub const fn with_position(self, position: BorderPosition) -> Self
pub const fn with_position(self, position: BorderPosition) -> Self
Sets the position of the line relative to the start and end points.
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for Line<F>
impl<F> RefUnwindSafe for Line<F>
impl<F> Send for Line<F>
impl<F> Sync for Line<F>
impl<F> Unpin for Line<F>
impl<F> UnwindSafe for Line<F>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more