Skip to content

Commit

Permalink
Adding playtime binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 7, 2023
1 parent 8800ccb commit 0d48d55
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ name = "magic"

[[bin]]
name = "weekly"

[[bin]]
name = "playtime"
29 changes: 29 additions & 0 deletions src/bin/playtime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use weekly::{Colors, HasRenderAttrs, Instructions, NumericUnit, Result, sizes, WLine};

fn main() -> Result<()> {
let page_bounds = sizes::letter();
weekly::save_one_page_document("foo", "playtime.pdf", &page_bounds, |_doc, bounds| {
let mut instructions = Instructions::default();

instructions.set_stroke_color(Colors::black());

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(),);
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(),);
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(),);
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);
instructions.push_shape(half_line.stroke());

Ok(instructions)
})
}

0 comments on commit 0d48d55

Please sign in to comment.