[Refactor] Convert hour_name_font_size to a constant
This commit is contained in:
parent
eaf111f216
commit
dcde43831b
12
src/main.rs
12
src/main.rs
@ -26,6 +26,7 @@ const HOUR_NAMES: [&str; 24] = [
|
|||||||
"Mushroom", "Thunder", "Frost", "Lantern",
|
"Mushroom", "Thunder", "Frost", "Lantern",
|
||||||
];
|
];
|
||||||
const IMAGE_WIDTH: u32 = 700;
|
const IMAGE_WIDTH: u32 = 700;
|
||||||
|
const HOUR_NAME_FONT_SIZE: f32 = IMAGE_WIDTH as f32 * 0.019109;
|
||||||
|
|
||||||
enum Season {
|
enum Season {
|
||||||
Spring,
|
Spring,
|
||||||
@ -95,7 +96,6 @@ fn hour_marker(
|
|||||||
is_current_hour: bool,
|
is_current_hour: bool,
|
||||||
outer_r: f32,
|
outer_r: f32,
|
||||||
ring_width: f32,
|
ring_width: f32,
|
||||||
hour_name_font_size: f32,
|
|
||||||
utc_hour_font_size: f32,
|
utc_hour_font_size: f32,
|
||||||
) -> Group {
|
) -> Group {
|
||||||
let season = match hour {
|
let season = match hour {
|
||||||
@ -142,7 +142,7 @@ fn hour_marker(
|
|||||||
let hour_name_text = Text::new()
|
let hour_name_text = Text::new()
|
||||||
.set("text-anchor", "middle")
|
.set("text-anchor", "middle")
|
||||||
.set("dominant-baseline", "mathematical")
|
.set("dominant-baseline", "mathematical")
|
||||||
.set("font-size", hour_name_font_size)
|
.set("font-size", HOUR_NAME_FONT_SIZE)
|
||||||
.add(hour_name_text_path);
|
.add(hour_name_text_path);
|
||||||
|
|
||||||
let utc_hour_text = Text::new()
|
let utc_hour_text = Text::new()
|
||||||
@ -268,10 +268,9 @@ fn gen_svg(config: &Option<Config>) -> Document {
|
|||||||
let moon_phase = moon_illumination.phase * 28.0;
|
let moon_phase = moon_illumination.phase * 28.0;
|
||||||
|
|
||||||
let local_hour_font_size = IMAGE_WIDTH as f32 * 0.02357;
|
let local_hour_font_size = IMAGE_WIDTH as f32 * 0.02357;
|
||||||
let hour_name_font_size = IMAGE_WIDTH as f32 * 0.019109;
|
|
||||||
let utc_hour_font_size = IMAGE_WIDTH as f32 * 0.021462;
|
let utc_hour_font_size = IMAGE_WIDTH as f32 * 0.021462;
|
||||||
let outer_r = (IMAGE_WIDTH as f32) / 2.0 - 3.0 * hour_name_font_size;
|
let outer_r = (IMAGE_WIDTH as f32) / 2.0 - 3.0 * HOUR_NAME_FONT_SIZE;
|
||||||
let ring_width = hour_name_font_size * 3.0;
|
let ring_width = HOUR_NAME_FONT_SIZE * 3.0;
|
||||||
let sun_radius = IMAGE_WIDTH as f32 * 0.0142871;
|
let sun_radius = IMAGE_WIDTH as f32 * 0.0142871;
|
||||||
let marker_radius = outer_r - ring_width - 2.0 * utc_hour_font_size;
|
let marker_radius = outer_r - ring_width - 2.0 * utc_hour_font_size;
|
||||||
|
|
||||||
@ -351,7 +350,6 @@ fn gen_svg(config: &Option<Config>) -> Document {
|
|||||||
hour == utc_hour as i32,
|
hour == utc_hour as i32,
|
||||||
outer_r,
|
outer_r,
|
||||||
ring_width,
|
ring_width,
|
||||||
hour_name_font_size,
|
|
||||||
utc_hour_font_size,
|
utc_hour_font_size,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -530,7 +528,7 @@ fn gen_svg(config: &Option<Config>) -> Document {
|
|||||||
.set("x2", IMAGE_WIDTH / 2)
|
.set("x2", IMAGE_WIDTH / 2)
|
||||||
.set(
|
.set(
|
||||||
"y2",
|
"y2",
|
||||||
IMAGE_WIDTH as f32 / 2.0 + outer_r - ring_width + hour_name_font_size,
|
IMAGE_WIDTH as f32 / 2.0 + outer_r - ring_width + HOUR_NAME_FONT_SIZE,
|
||||||
);
|
);
|
||||||
|
|
||||||
let current_box_width = (200f32 / 700f32) * IMAGE_WIDTH as f32;
|
let current_box_width = (200f32 / 700f32) * IMAGE_WIDTH as f32;
|
||||||
|
Loading…
Reference in New Issue
Block a user