[Refactor] Move some constants to a new module

This commit is contained in:
Gergely Polonkai 2022-05-22 18:58:27 +02:00
parent cba5372b4d
commit b95c035133
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 13 additions and 10 deletions

View File

@ -18,17 +18,11 @@ use svg::node::element::{
use svg::node::Text as TextNode; use svg::node::Text as TextNode;
use svg::Document; use svg::Document;
sctk::default_environment!(SeasonalClock, desktop); mod svg_clock;
const HOUR_NAMES: [&str; 24] = [ use svg_clock::{HOUR_NAMES, HOUR_NAME_FONT_SIZE, IMAGE_WIDTH, OUTER_R, RING_WIDTH};
"Candle", "Ice", "Comet", "Thimble", "Root", "Mist", "Sprout", "Rainbow", "Worm", "Bud",
"Blossom", "Ladybug", "Geese", "Dust", "Peach", "Fog", "Acorn", "Gourd", "Soup", "Crow", sctk::default_environment!(SeasonalClock, desktop);
"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;
enum Season { enum Season {
Spring, Spring,

9
src/svg_clock.rs Normal file
View File

@ -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;