Skip to content

Commit

Permalink
Removing LineModifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 7, 2023
1 parent 0d48d55 commit 9236de7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 32 deletions.
15 changes: 10 additions & 5 deletions src/bin/playtime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use weekly::{Colors, HasRenderAttrs, Instructions, NumericUnit, Result, sizes, WLine};
use weekly::{sizes, Colors, HasRenderAttrs, Instructions, NumericUnit, Result, WLine};

fn main() -> Result<()> {
let page_bounds = sizes::letter();
Expand All @@ -10,18 +10,23 @@ fn main() -> Result<()> {
let whole_page_rect = bounds.clone();
instructions.push_shape(whole_page_rect.stroke());

let one_mm_rect = bounds.inset_all_q1(1.0.mm(),1.0.mm(),1.0.mm(),1.0.mm(),);
let one_mm_rect = bounds.inset_all_q1(1.0.mm(), 1.0.mm(), 1.0.mm(), 1.0.mm());
instructions.push_shape(one_mm_rect.stroke());

let five_mm_rect = bounds.inset_all_q1(5.0.mm(),5.0.mm(),5.0.mm(),5.0.mm(),);
let five_mm_rect = bounds.inset_all_q1(5.0.mm(), 5.0.mm(), 5.0.mm(), 5.0.mm());
instructions.push_shape(five_mm_rect.stroke());

let ten_mm_rect = bounds.inset_all_q1(10.0.mm(),10.0.mm(),10.0.mm(),10.0.mm(),);
let ten_mm_rect = bounds.inset_all_q1(10.0.mm(), 10.0.mm(), 10.0.mm(), 10.0.mm());
instructions.push_shape(ten_mm_rect.stroke());

instructions.set_stroke_color(Colors::gray(0.75));
instructions.set_dash(7, 3);
let half_line = WLine::line(page_bounds.left(), page_bounds.height() / 2.0, page_bounds.right(), page_bounds.height() / 2.0);
let half_line = WLine::line(
page_bounds.left(),
page_bounds.height() / 2.0,
page_bounds.right(),
page_bounds.height() / 2.0,
);
instructions.push_shape(half_line.stroke());

Ok(instructions)
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use thiserror::Error;

pub use datetools::{today, Datetools};
pub use pdfutils::sizes;
pub use pdfutils::FontProxy;
//pub use pdfutils::FontProxy;
pub use pdfutils::{
save_double_sided_document, save_one_page_document, Attributes, Colors, Instructions,
LineModifiers, TextContext,
save_double_sided_document, save_one_page_document, Attributes, Colors, FontProxy, Instructions,
TextContext,
};
pub use shapes::circle::Circle;
pub use shapes::line::WLine;
Expand Down
17 changes: 0 additions & 17 deletions src/pdfutils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,6 @@ impl Colors {
}
}

pub trait LineModifiers {
fn stroke(self, value: bool) -> Self;
fn fill(self, value: bool) -> Self;
}

impl LineModifiers for Line {
fn stroke(mut self, value: bool) -> Self {
self.has_stroke = value;
self
}

fn fill(mut self, value: bool) -> Self {
self.has_fill = value;
self
}
}

pub fn save_one_page_document<F>(
title: &str,
filename: impl AsRef<Path>,
Expand Down
9 changes: 2 additions & 7 deletions src/shapes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::LineModifiers;
use printpdf::Line;

pub(crate) mod circle;
Expand Down Expand Up @@ -101,12 +100,8 @@ where
let filled = self.is_filled();
let mut line = self.to_plain_pdf_line();
// TODO: This is a little awkward.
if stroked {
line = line.stroke(true);
}
if filled {
line = line.fill(true);
}
line.has_stroke = stroked;
line.has_fill = filled;
line
}
}

0 comments on commit 9236de7

Please sign in to comment.