From a613855a66dd3a5f5dccb18b07fe70a72e7764a0 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 18 May 2022 17:10:55 +0200 Subject: [PATCH] Add a Sun disc to the dial It rises on the horizon ^_^ --- src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.rs b/src/main.rs index 787aaf5..5b1b407 100644 --- a/src/main.rs +++ b/src/main.rs @@ -216,6 +216,7 @@ fn gen_svg() -> Document { .day-time {stroke: none; fill: rgb(125, 197, 240);} .moon-background {stroke: rgb(170, 170, 170); stroke-width: 2px; fill: rgb(19, 17, 30);} .moon {stroke: none; fill: rgb(170, 170, 170);} + .sun {stroke: none; fill: rgb(238, 187, 85);} .mid-marker {stroke: red;} .dial {stroke-width: 2px; stroke: rgb(238, 187, 85);}", ); @@ -277,6 +278,21 @@ fn gen_svg() -> Document { evening_golden_start, ); + let sun_disc = Circle::new() + .set("class", "sun") + .set("cx", image_width / 2) + .set("cy", image_width as f32 / 2.0 + outer_r / 2.0 + sun_radius) + .set("r", sun_radius) + .set( + "transform", + format!( + "rotate({}, {}, {})", + time_to_degrees(local_time), + image_width / 2, + image_width / 2 + ), + ); + let blue_hour_path = get_range_path( image_width, marker_radius, @@ -291,6 +307,7 @@ fn gen_svg() -> Document { .set("id", "day-parts") .add(daytime_circle) .add(golden_hour_path) + .add(sun_disc) .add(blue_hour_path) .add(nighttime_path);