Skip to content

Commit

Permalink
to_pdf_line() now takes a ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 6, 2023
1 parent a18ddb1 commit fc16555
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/shapes/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl AsMut<RenderAttrsImpl> for Circle {
}

impl ToPlainPdfLine for Circle {
fn to_plain_pdf_line(self) -> Line {
fn to_plain_pdf_line(&self) -> Line {
Line {
points: printpdf::calculate_points_for_circle(self.radius, self.x, self.y),
is_closed: true,
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl AsMut<RenderAttrsImpl> for WLine {
}

impl ToPlainPdfLine for WLine {
fn to_plain_pdf_line(self) -> Line {
fn to_plain_pdf_line(&self) -> Line {
Line {
points: vec![
point_pair(self.x1, self.y1, false),
Expand Down
13 changes: 6 additions & 7 deletions src/shapes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ impl<T: AsMut<RenderAttrsImpl> + AsRef<RenderAttrsImpl>> HasRenderAttrs for T {
trait ToPlainPdfLine {
/// Converts a shape into an (unstroke, unfilled) printpdf::line.
/// The implementor is responsible for setting the 'closed' flag.
// TODO: consider making this take &self and rename to AsPlainPdfLine.
fn to_plain_pdf_line(self) -> Line;
fn to_plain_pdf_line(&self) -> Line;
}

pub trait ToPdfLine {
/// Converts a shape into a printpdf::Line that is marked for rendering as a stroke
/// or a filled shape (or both).
// TODO: consider making this take &self and rename to AsPdfLine.
fn to_pdf_line(self) -> Line;
fn to_pdf_line(&self) -> Line;
}

impl<T> ToPdfLine for T
where
T: ToPlainPdfLine + HasRenderAttrs,
{
fn to_pdf_line(self) -> Line {
fn to_pdf_line(&self) -> Line {
// TODO: Do you want to check that plain pdf line is unstroked and unfilled?
let stroked = self.is_stroked();
let filled = self.is_filled();
Expand All @@ -114,7 +112,8 @@ where
}

impl ToPdfLine for Line {
fn to_pdf_line(self) -> Line {
self
fn to_pdf_line(&self) -> Line {
// TODO: make this thing go awqy! I think it's only used for rounded rects.
self.clone()
}
}
2 changes: 1 addition & 1 deletion src/shapes/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl AsMut<RenderAttrsImpl> for WRect {
}

impl ToPlainPdfLine for WRect {
fn to_plain_pdf_line(self) -> Line {
fn to_plain_pdf_line(&self) -> Line {
Line {
// In Q1, rects grow downward toward the bottom.
points: vec![
Expand Down

0 comments on commit fc16555

Please sign in to comment.