[Refactor] Move some constants to a new module
This commit is contained in:
parent
cba5372b4d
commit
b95c035133
14
src/main.rs
14
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,
|
||||
|
9
src/svg_clock.rs
Normal file
9
src/svg_clock.rs
Normal 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;
|
Loading…
Reference in New Issue
Block a user