Colour hour name plates based on their season

This commit is contained in:
Gergely Polonkai 2022-05-19 05:04:48 +02:00
parent e24e199e9e
commit 6e0dedb1fb
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4

View File

@ -33,12 +33,16 @@ enum Season {
impl fmt::Display for Season {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", match self {
Season::Spring => "spring",
Season::Summer => "summer",
Season::Autumn => "autumn",
Season::Winter => "winter",
})
write!(
f,
"{}",
match self {
Season::Spring => "spring",
Season::Summer => "summer",
Season::Autumn => "autumn",
Season::Winter => "winter",
}
)
}
}
@ -79,6 +83,13 @@ fn hour_marker(
hour_name_font_size: f32,
utc_hour_font_size: f32,
) -> Group {
let season = match hour {
0..=5 => Season::Winter,
6..=11 => Season::Spring,
12..=17 => Season::Summer,
18..=23 => Season::Autumn,
_ => panic!("Hour out of range"),
};
let rotation = hour * 15;
let delta_x = outer_r * (15f32.to_radians() / 2.0).sin();
@ -133,7 +144,7 @@ fn hour_marker(
.add(TextNode::new(format!("U {:02}", hour)));
Group::new()
.set("class", "hour")
.set("class", format!("hour {season}"))
.set(
"transform",
format!(
@ -298,6 +309,10 @@ fn gen_svg() -> Document {
.hour path {stroke: rgb(0, 0, 0); stroke-width: 2px;}
.hour text {stroke: none; fill: rgb(238, 187, 85);}
.hour text.utc {stroke: none; fill: rgb(91, 68, 38);}
.winter path {fill: rgb(70, 62, 108);}
.spring path {fill: rgb(55, 87, 55);}
.summer path {fill: rgb(113, 92, 43);}
.autumn path {fill: rgb(108, 68, 44);}
.local-hour {stroke: none; fill: rgb(238, 187, 85);}
.night-time {stroke: none; fill: rgb(19, 17, 30);}
.blue-hour {stroke: none; fill: rgb(9, 1, 119);}