Skip to content

Commit

Permalink
Minor cleanup: creating as_rect_shape()
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 7, 2023
1 parent 94b673e commit 27889dc
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/shapes/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ impl WRect {
..Line::default()
}
}

fn as_rect_shape(&self) -> Line {
Line {
// In Q1, rects grow downward toward the bottom.
points: vec![
point_pair(self.left, self.top, false),
point_pair(self.left + self.width, self.top, false),
point_pair(self.left + self.width, self.top - self.height, false),
point_pair(self.left, self.top - self.height, false),
],
is_closed: true,
..Line::default()
}
}
}

impl AsRef<RenderAttrsImpl> for WRect {
Expand All @@ -152,17 +166,7 @@ impl ToPlainPdfLine for WRect {
if let Some(radius) = self.corner_radius {
self.as_rounded_rect_shape(radius)
} else {
Line {
// In Q1, rects grow downward toward the bottom.
points: vec![
point_pair(self.left, self.top, false),
point_pair(self.left + self.width, self.top, false),
point_pair(self.left + self.width, self.top - self.height, false),
point_pair(self.left, self.top - self.height, false),
],
is_closed: true,
..Line::default()
}
self.as_rect_shape()
}
}
}

0 comments on commit 27889dc

Please sign in to comment.