Skip to content

Commit

Permalink
Cleaning up some shape ctors.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 7, 2023
1 parent 27889dc commit 2f9640d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/shapes/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::shapes::{RenderAttrsImpl, ToPlainPdfLine};
use crate::{NumericUnit, Unit};
use printpdf::Line;

#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Circle {
render_attrs: RenderAttrsImpl,

Expand All @@ -14,19 +14,19 @@ pub struct Circle {
impl Circle {
pub fn at_zero(radius: Unit) -> Circle {
Circle {
render_attrs: RenderAttrsImpl::default(),
radius,
x: Unit::zero(),
y: Unit::zero(),
..Self::default()
}
}

pub fn unit_at(x: Unit, y: Unit) -> Circle {
Circle {
render_attrs: RenderAttrsImpl::default(),
radius: 1.0.mm(),
x,
y,
..Self::default()
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/shapes/rect.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::default::Default;
use crate::pdfutils::point_pair;
use crate::shapes::{RenderAttrsImpl, ToPlainPdfLine};
use crate::units::Unit;
use printpdf::*;

/// A representation of rectangles and operations on them.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub struct WRect {
render_attrs: RenderAttrsImpl,
corner_radius: Option<Unit>,
Expand All @@ -29,12 +30,9 @@ impl WRect {

pub fn at(left: Unit, top: Unit) -> WRect {
WRect {
render_attrs: RenderAttrsImpl::default(),
corner_radius: None,
top,
left,
width: Unit::zero(),
height: Unit::zero(),
..Self::default()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/units.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
#[derive(Debug, Default, PartialEq, PartialOrd, Copy, Clone)]
// A `Unit` is a number of millimeters (mm) internally.
pub struct Unit(f64);

Expand Down

0 comments on commit 2f9640d

Please sign in to comment.