From b95c0351338f56294752bd4b86d2e9cb3967b4d6 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 22 May 2022 18:58:27 +0200 Subject: [PATCH] [Refactor] Move some constants to a new module --- src/main.rs | 14 ++++---------- src/svg_clock.rs | 9 +++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/svg_clock.rs diff --git a/src/main.rs b/src/main.rs index 4317510..b11e715 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,17 +18,11 @@ use svg::node::element::{ use svg::node::Text as TextNode; use svg::Document; -sctk::default_environment!(SeasonalClock, desktop); +mod svg_clock; -const HOUR_NAMES: [&str; 24] = [ - "Candle", "Ice", "Comet", "Thimble", "Root", "Mist", "Sprout", "Rainbow", "Worm", "Bud", - "Blossom", "Ladybug", "Geese", "Dust", "Peach", "Fog", "Acorn", "Gourd", "Soup", "Crow", - "Mushroom", "Thunder", "Frost", "Lantern", -]; -const IMAGE_WIDTH: u32 = 700; -const HOUR_NAME_FONT_SIZE: f32 = IMAGE_WIDTH as f32 * 0.019109; -const OUTER_R: f32 = (IMAGE_WIDTH as f32) / 2.0 - 3.0 * HOUR_NAME_FONT_SIZE; -const RING_WIDTH: f32 = HOUR_NAME_FONT_SIZE * 3.0; +use svg_clock::{HOUR_NAMES, HOUR_NAME_FONT_SIZE, IMAGE_WIDTH, OUTER_R, RING_WIDTH}; + +sctk::default_environment!(SeasonalClock, desktop); enum Season { Spring, diff --git a/src/svg_clock.rs b/src/svg_clock.rs new file mode 100644 index 0000000..92def91 --- /dev/null +++ b/src/svg_clock.rs @@ -0,0 +1,9 @@ +pub const HOUR_NAMES: [&str; 24] = [ + "Candle", "Ice", "Comet", "Thimble", "Root", "Mist", "Sprout", "Rainbow", "Worm", "Bud", + "Blossom", "Ladybug", "Geese", "Dust", "Peach", "Fog", "Acorn", "Gourd", "Soup", "Crow", + "Mushroom", "Thunder", "Frost", "Lantern", +]; +pub const IMAGE_WIDTH: u32 = 700; +pub const HOUR_NAME_FONT_SIZE: f32 = IMAGE_WIDTH as f32 * 0.019109; +pub const OUTER_R: f32 = (IMAGE_WIDTH as f32) / 2.0 - 3.0 * HOUR_NAME_FONT_SIZE; +pub const RING_WIDTH: f32 = HOUR_NAME_FONT_SIZE * 3.0;