pub struct Stroke {
pub color: Color,
pub width: f64,
pub cap: LineCap,
pub join: LineJoin,
pub miter_limit: MiterLimit,
pub dash: Option<Dash>,
}Expand description
A stroke’s colour, width and pen shape, in canvas units.
The fields stay public and every one but color and width has a
default, so Stroke { cap: LineCap::Round, ..Stroke::new(color, 1.0) }
works and the four settings ISO 32000-1 §8.4.3.3-§8.4.3.6 name are
reachable without builder ceremony. Stroke::new keeps meaning what it
always meant: PDF’s own defaults — butt cap, miter join, miter limit 10,
no dash.
Fields§
§color: ColorThe colour. Its alpha is honoured, as an /ExtGState /CA.
width: f64The line width in canvas units — page points.
cap: LineCapHow the open ends of a subpath are drawn. J.
join: LineJoinHow two segments meet at a corner. j.
miter_limit: MiterLimitWhere a LineJoin::Miter corner becomes a bevel instead, as the
ratio of miter length to line width. M.
dash: Option<Dash>The on/off pattern, or None for a solid line. d.
Implementations§
Source§impl Stroke
impl Stroke
Sourcepub fn new(color: Color, width: f64) -> Self
pub fn new(color: Color, width: f64) -> Self
A solid stroke of color at width points, with PDF’s default pen:
butt cap, miter join, miter limit 10.
let hairline = pdfrum::Stroke::new(pdfrum::Color::BLACK, 0.5);
assert_eq!(hairline.width, 0.5);
assert_eq!(hairline.cap, pdfrum::LineCap::Butt);
assert!(hairline.dash.is_none());Sourcepub fn with_cap(self, cap: LineCap) -> Self
pub fn with_cap(self, cap: LineCap) -> Self
The same stroke with cap at its open ends.
use pdfrum::{Color, LineCap, Stroke};
let round = Stroke::new(Color::BLACK, 4.0).with_cap(LineCap::Round);
assert_eq!(round.cap, LineCap::Round);Sourcepub fn with_join(self, join: LineJoin) -> Self
pub fn with_join(self, join: LineJoin) -> Self
The same stroke with join at its corners.
use pdfrum::{Color, LineJoin, Stroke};
let soft = Stroke::new(Color::BLACK, 4.0).with_join(LineJoin::Round);
assert_eq!(soft.join, LineJoin::Round);Sourcepub fn with_miter_limit(self, limit: MiterLimit) -> Self
pub fn with_miter_limit(self, limit: MiterLimit) -> Self
The same stroke with limit on its miter joins.
use pdfrum::{Color, MiterLimit, Stroke};
let blunt = Stroke::new(Color::BLACK, 4.0).with_miter_limit(MiterLimit::new(2.0));
assert_eq!(blunt.miter_limit.get(), 2.0);Trait Implementations§
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.