[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",
|
||||
];
|
||||
const IMAGE_WIDTH: u32 = 700;
|
||||
const HOUR_NAME_FONT_SIZE: f32 = IMAGE_WIDTH as f32 * 0.019109;
|
||||
|
||||
enum Season {
|
||||
Spring,
|
||||
@ -95,7 +96,6 @@ fn hour_marker(
|
||||
is_current_hour: bool,
|
||||
outer_r: f32,
|
||||
ring_width: f32,
|
||||
hour_name_font_size: f32,
|
||||
utc_hour_font_size: f32,
|
||||
) -> Group {
|
||||
let season = match hour {
|
||||
@ -142,7 +142,7 @@ fn hour_marker(
|
||||
let hour_name_text = Text::new()
|
||||
.set("text-anchor", "middle")
|
||||
.set("dominant-baseline", "mathematical")
|
||||
.set("font-size", hour_name_font_size)
|
||||
.set("font-size", HOUR_NAME_FONT_SIZE)
|
||||
.add(hour_name_text_path);
|
||||
|
||||
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 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 outer_r = (IMAGE_WIDTH as f32) / 2.0 - 3.0 * hour_name_font_size;
|
||||
let ring_width = hour_name_font_size * 3.0;
|
||||
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 sun_radius = IMAGE_WIDTH as f32 * 0.0142871;
|
||||
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,
|
||||
outer_r,
|
||||
ring_width,
|
||||
hour_name_font_size,
|
||||
utc_hour_font_size,
|
||||
));
|
||||
}
|
||||
@ -530,7 +528,7 @@ fn gen_svg(config: &Option<Config>) -> Document {
|
||||
.set("x2", IMAGE_WIDTH / 2)
|
||||
.set(
|
||||
"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;
|
||||
|
Loading…
Reference in New Issue
Block a user