Colour hour name plates based on their season
This commit is contained in:
parent
e24e199e9e
commit
6e0dedb1fb
21
src/main.rs
21
src/main.rs
@ -33,12 +33,16 @@ enum Season {
|
|||||||
|
|
||||||
impl fmt::Display for Season {
|
impl fmt::Display for Season {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", match self {
|
write!(
|
||||||
|
f,
|
||||||
|
"{}",
|
||||||
|
match self {
|
||||||
Season::Spring => "spring",
|
Season::Spring => "spring",
|
||||||
Season::Summer => "summer",
|
Season::Summer => "summer",
|
||||||
Season::Autumn => "autumn",
|
Season::Autumn => "autumn",
|
||||||
Season::Winter => "winter",
|
Season::Winter => "winter",
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +83,13 @@ fn hour_marker(
|
|||||||
hour_name_font_size: f32,
|
hour_name_font_size: f32,
|
||||||
utc_hour_font_size: f32,
|
utc_hour_font_size: f32,
|
||||||
) -> Group {
|
) -> 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 rotation = hour * 15;
|
||||||
|
|
||||||
let delta_x = outer_r * (15f32.to_radians() / 2.0).sin();
|
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)));
|
.add(TextNode::new(format!("U {:02}", hour)));
|
||||||
|
|
||||||
Group::new()
|
Group::new()
|
||||||
.set("class", "hour")
|
.set("class", format!("hour {season}"))
|
||||||
.set(
|
.set(
|
||||||
"transform",
|
"transform",
|
||||||
format!(
|
format!(
|
||||||
@ -298,6 +309,10 @@ fn gen_svg() -> Document {
|
|||||||
.hour path {stroke: rgb(0, 0, 0); stroke-width: 2px;}
|
.hour path {stroke: rgb(0, 0, 0); stroke-width: 2px;}
|
||||||
.hour text {stroke: none; fill: rgb(238, 187, 85);}
|
.hour text {stroke: none; fill: rgb(238, 187, 85);}
|
||||||
.hour text.utc {stroke: none; fill: rgb(91, 68, 38);}
|
.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);}
|
.local-hour {stroke: none; fill: rgb(238, 187, 85);}
|
||||||
.night-time {stroke: none; fill: rgb(19, 17, 30);}
|
.night-time {stroke: none; fill: rgb(19, 17, 30);}
|
||||||
.blue-hour {stroke: none; fill: rgb(9, 1, 119);}
|
.blue-hour {stroke: none; fill: rgb(9, 1, 119);}
|
||||||
|
Loading…
Reference in New Issue
Block a user