From 7f352ac256bfe8cd2c4290bc94ad1a21af2490b0 Mon Sep 17 00:00:00 2001
From: siflfran <siflfran>
Date: Wed, 26 Apr 2006 08:27:21 +0000
Subject: [PATCH] Sonnenuntergang eingezeichnet

---
 01_git/astime_x.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/01_git/astime_x.c b/01_git/astime_x.c
index abe82b6..b23a29e 100644
--- a/01_git/astime_x.c
+++ b/01_git/astime_x.c
@@ -12,7 +12,8 @@
 #define CIVIL_TWILIGHT 1
 #define NAUT_TWILIGHT  2
 #define ASTRO_TWILIGHT 3
-#define DARKNESS       4
+#define SUNRISESET     4
+#define DARKNESS       5
 #define SUNRISET_SIZE  .618033989
 
 #include <stdio.h>
@@ -75,7 +76,7 @@ char digits_pixmap_color[2][32];
 char months_pixmap_color[2][32];
 
 Pixel back_pix, fore_pix;
-Pixel day_pix, night_pix, astro_pix, naut_pix;
+Pixel day_pix, night_pix, astro_pix, naut_pix, civil_pix;
 
 /* The center of the clock */
 struct coordinates center;
@@ -120,7 +121,8 @@ void draw_sunriset(Window win,
 	double start, end;
 	
 	assert(type == CIVIL_TWILIGHT || type == NAUT_TWILIGHT 
-			|| type == ASTRO_TWILIGHT || type == DARKNESS);
+			|| type == ASTRO_TWILIGHT || type == SUNRISESET
+			|| type == DARKNESS);
 	XSetForeground(mainDisplay, mainGC, color);
 	x = center.x - (watch_size.x * size);
 	y = center.y - (watch_size.y * size);
@@ -156,6 +158,16 @@ void draw_sunriset(Window win,
 		} else if (-1 == ret) {
 			return;
 		}
+	} else if (SUNRISESET == type) {
+		int ret;
+		ret = sun_rise_set(local_time->tm_year, local_time->tm_mon, 
+			local_time->tm_mday, lat, lon, &start, &end);
+		if (1 == ret) {
+			XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64);
+			return;
+		} else if (-1 == ret) {
+			return;
+		}
 	} else if (DARKNESS == type) {
 		XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64);
 		return;
@@ -335,7 +347,9 @@ void draw_window(Window win)
 		draw_sunriset(win, loc_time,
 			   	state.lon, state.lat, naut_pix, SUNRISET_SIZE, NAUT_TWILIGHT);
 		draw_sunriset(win, loc_time,
-			   	state.lon, state.lat, day_pix, SUNRISET_SIZE, CIVIL_TWILIGHT);
+			   	state.lon, state.lat, civil_pix, SUNRISET_SIZE, CIVIL_TWILIGHT);
+		draw_sunriset(win, loc_time,
+			   	state.lon, state.lat, day_pix, SUNRISET_SIZE, SUNRISESET);
 	}
 	/* draw filled polygonal hands */
 	for (i = 2; i >= 0; i--) {
@@ -842,10 +856,12 @@ void initialize(int argc, char **argv,
 	fore_pix = GetColor(state.fgcolor, mainDisplay, Root);
 	day_pix = GetColor(state.sunrisetday, mainDisplay, Root);
 	night_pix = GetColor(state.sunrisetnight, mainDisplay, Root);
-	naut_pix = MixColors(state.sunrisetday, 
-			state.sunrisetnight, .6, mainDisplay, Root);
 	astro_pix = MixColors(state.sunrisetday, 
-			state.sunrisetnight, .3, mainDisplay, Root);
+			state.sunrisetnight, .25, mainDisplay, Root);
+	naut_pix = MixColors(state.sunrisetday, 
+			state.sunrisetnight, .5, mainDisplay, Root);
+	civil_pix = MixColors(state.sunrisetday, 
+			state.sunrisetnight, .75, mainDisplay, Root);
 	color_depth = DefaultDepth(mainDisplay, screen);
 #ifdef DEBUG
 	printf("astime : detected color depth %d bpp, using %d bpp\n",
-- 
GitLab