From dc5253f616a1e3eb4f78654e30b4b773b62d85f4 Mon Sep 17 00:00:00 2001
From: siflfran <siflfran>
Date: Tue, 2 May 2006 17:22:19 +0000
Subject: [PATCH] Neon-Krams

---
 01_git/astime_x.c   | 98 ++++++++++++++++++++++++++++++++++++++-------
 01_git/beo.astimerc |  2 +-
 2 files changed, 84 insertions(+), 16 deletions(-)

diff --git a/01_git/astime_x.c b/01_git/astime_x.c
index 5550a25..e49968d 100644
--- a/01_git/astime_x.c
+++ b/01_git/astime_x.c
@@ -31,6 +31,7 @@
 #include "x_color.h"
 #include "x_primitives.h"
 #include "state.h"
+#include "safecopy.h"
 
 struct astime_state state;
 
@@ -78,6 +79,7 @@ char months_pixmap_color[2][32];
 
 Pixel back_pix, fore_pix;
 Pixel day_pix, night_pix, astro_pix, naut_pix, civil_pix;
+Pixel oday_pix, onight_pix, oastro_pix, onaut_pix, ocivil_pix;
 
 /* The center of the clock */
 struct coordinates center;
@@ -114,6 +116,7 @@ void draw_sunriset(Window win,
 		double lon,
 		double lat,
 		int color, 
+		int neoncolor,
 		float size,
 		int type);
 void draw_window(Window win);
@@ -148,6 +151,7 @@ void draw_sunriset(Window win,
 		double lon,
 		double lat,
 		int color, 
+		int neoncolor,
 		float size,
 		int type)
 {
@@ -155,11 +159,17 @@ void draw_sunriset(Window win,
 	unsigned int width, height;
 	int angle1, angle2;
 	double start, end;
+	GC neonGC;
 	
 	assert(type == CIVIL_TWILIGHT || type == NAUT_TWILIGHT 
 			|| type == ASTRO_TWILIGHT || type == SUNRISESET
 			|| type == DARKNESS);
+	neonGC = XCreateGC(mainDisplay,
+		   mainWindow,
+		   GCForeground | GCLineWidth,
+		   &mainGCV);
 	XSetForeground(mainDisplay, mainGC, color);
+	XSetForeground(mainDisplay, neonGC, neoncolor);
 	x = center.x;
 	y = center.y;
 	width = watch_size.x * size;
@@ -171,6 +181,8 @@ void draw_sunriset(Window win,
 		if (1 == ret) {
 			FillCenteredArc(mainDisplay, win, mainGC, 
 					x, y, width, height, 0 * 64, 359 * 64);
+			DrawCenteredArc(mainDisplay, win, neonGC, 
+					x, y, width, height, 0 * 64, 359 * 64);
 			return;
 		} else if (-1 == ret) {
 			return;
@@ -182,6 +194,8 @@ void draw_sunriset(Window win,
 		if (1 == ret) {
 			FillCenteredArc(mainDisplay, win, mainGC, 
 					x, y, width, height, 0 * 64, 359 * 64);
+			DrawCenteredArc(mainDisplay, win, neonGC, 
+					x, y, width, height, 0 * 64, 359 * 64);
 			return;
 		} else if (-1 == ret) {
 			return;
@@ -193,6 +207,8 @@ void draw_sunriset(Window win,
 		if (1 == ret) {
 			FillCenteredArc(mainDisplay, win, mainGC, 
 					x, y, width, height, 0 * 64, 359 * 64);
+			DrawCenteredArc(mainDisplay, win, neonGC, 
+					x, y, width, height, 0 * 64, 359 * 64);
 			return;
 		} else if (-1 == ret) {
 			return;
@@ -204,6 +220,8 @@ void draw_sunriset(Window win,
 		if (1 == ret) {
 			FillCenteredArc(mainDisplay, win, mainGC, 
 					x, y, width, height, 0 * 64, 359 * 64);
+			DrawCenteredArc(mainDisplay, win, neonGC, 
+					x, y, width, height, 0 * 64, 359 * 64);
 			return;
 		} else if (-1 == ret) {
 			return;
@@ -211,6 +229,8 @@ void draw_sunriset(Window win,
 	} else if (DARKNESS == type) {
 		FillCenteredArc(mainDisplay, win, mainGC,
 			   	x, y, width, height, 0 * 64, 359 * 64);
+		DrawCenteredArc(mainDisplay, win, neonGC,
+			   	x, y, width, height, 0 * 64, 359 * 64);
 		return;
 	}
 	angle1 = (int) rint(start * 15.0);
@@ -223,6 +243,8 @@ void draw_sunriset(Window win,
 	}
 	FillCenteredArc(mainDisplay, win, mainGC, x, y, width, height, 
 			(360 - angle1 - 90) * 64, -angle2 * 64);
+	DrawCenteredArc(mainDisplay, win, neonGC, x, y, width, height, 
+			(360 - angle1 - 90) * 64, -angle2 * 64);
 }
 
 void draw_window(Window win)
@@ -379,15 +401,20 @@ void draw_window(Window win)
 	/* draw sunrise and sunset */
 	if (state.twentyfour && state.sunriset) {
 		draw_sunriset(win, loc_time, 
-				state.lon, state.lat, night_pix, SUNRISET_SIZE, DARKNESS);
+				state.lon, state.lat, night_pix, onight_pix, SUNRISET_SIZE, 
+				DARKNESS);
 		draw_sunriset(win, loc_time, 
-				state.lon, state.lat, astro_pix, SUNRISET_SIZE, ASTRO_TWILIGHT);
+				state.lon, state.lat, astro_pix, oastro_pix,  SUNRISET_SIZE, 
+				ASTRO_TWILIGHT);
 		draw_sunriset(win, loc_time,
-			   	state.lon, state.lat, naut_pix, SUNRISET_SIZE, NAUT_TWILIGHT);
+			   	state.lon, state.lat, naut_pix, onaut_pix, SUNRISET_SIZE, 
+				NAUT_TWILIGHT);
 		draw_sunriset(win, loc_time,
-			   	state.lon, state.lat, civil_pix, SUNRISET_SIZE, CIVIL_TWILIGHT);
+			   	state.lon, state.lat, civil_pix, ocivil_pix, SUNRISET_SIZE, 
+				CIVIL_TWILIGHT);
 		draw_sunriset(win, loc_time,
-			   	state.lon, state.lat, day_pix, SUNRISET_SIZE, SUNRISESET);
+			   	state.lon, state.lat, day_pix, oday_pix, SUNRISET_SIZE, 
+				SUNRISESET);
 	}
 	/* draw filled polygonal hands */
 	for (i = 2; i >= 0; i--) {
@@ -749,20 +776,28 @@ void draw_dial(void)
 	short base_size, i;
 	float xrate, yrate;
 	XPoint coord;
+	GC neonGC;
+	neonGC = XCreateGC(mainDisplay,
+			   mainWindow,
+			   GCForeground | GCLineWidth,
+			   &mainGCV);
 
 	base_size = 5 * fmin(watch_size.x, watch_size.y) / 397;
 
 	for (i = 0; i < 120; i++) {
 		int size;
 		if (state.twentyfour ? i % 15 == 0 : i % 30 == 0) {
-			mainGCV.foreground = pix[8];
+			XSetForeground(mainDisplay, mainGC, pix[8]);
+			XSetForeground(mainDisplay, neonGC, pix[5]);
 			size = fmax(base_size * 3, 6);
 		} else if (state.twentyfour ? i % 5 == 0 : i % 10 == 0) {
-			mainGCV.foreground = pix[7];
+			XSetForeground(mainDisplay, mainGC, pix[7]);
+			XSetForeground(mainDisplay, neonGC, pix[4]);
 			size = base_size * 2;
 		} else if (i % 2 == 0) {
 			if (state.tprop == 2) {
-				mainGCV.foreground = pix[6];
+				XSetForeground(mainDisplay, mainGC, pix[6]);
+				XSetForeground(mainDisplay, neonGC, pix[3]);
 				size = base_size;
 			} else {
 				continue;
@@ -770,19 +805,22 @@ void draw_dial(void)
 		} else {
 			continue;
 		}
-		XChangeGC(mainDisplay, mainGC, GCForeground, &mainGCV);
 		xrate = convert2x(i / 2.0);
 		yrate = convert2y(i / 2.0);
 		coord.x = center.x + rint((watch_size.x + 1) * xrate);
 		coord.y = center.y + rint((watch_size.y + 1) * yrate);
 		if (size < 4 || size == base_size) {
-			XDrawPoint(mainDisplay, backgroundWindow, mainGC, coord.x, coord.y);
+			XDrawPoint(mainDisplay, backgroundWindow, neonGC, coord.x, coord.y);
 		} else {
 			FillTriangle(mainDisplay, backgroundWindow, mainGC, 
 					coord.x, coord.y, size, rint(.5 * size), 
 					sec_to_deg64(60 - i / 2.0));
+			DrawTriangle(mainDisplay, backgroundWindow, neonGC, 
+					coord.x, coord.y, size, rint(.5 * size), 
+					sec_to_deg64(60 - i / 2.0));
 		}
 	}
+	XFreeGC(mainDisplay, neonGC);
 }
 
 void initialize(int argc, char **argv,
@@ -823,14 +861,44 @@ void initialize(int argc, char **argv,
 	Root = RootWindow(mainDisplay, screen);
 	back_pix = GetColor(state.bgcolor, mainDisplay, Root);
 	fore_pix = GetColor(state.fgcolor, mainDisplay, Root);
-	day_pix = GetColor(state.sunrisetday, mainDisplay, Root);
-	night_pix = GetColor(state.sunrisetnight, mainDisplay, Root);
-	astro_pix = MixColors(state.sunrisetday, 
+
+	if (state.neon) {
+		char tmp_day[50]; 
+		char tmp_night[50];
+		
+		safecopy(tmp_day, DarkenCharColor(state.sunrisetday, 1.5, mainDisplay, Root), 50);
+		safecopy(tmp_night, DarkenCharColor(state.sunrisetnight, 1.5, mainDisplay, Root), 50);
+	
+		day_pix = GetColor(tmp_day, mainDisplay, Root);
+		night_pix = GetColor(tmp_night, mainDisplay, Root);
+		astro_pix = GetColor(MixCharColors(tmp_day, tmp_night, .25, 
+					mainDisplay, Root), 
+				mainDisplay, Root);
+		naut_pix = GetColor(MixCharColors(tmp_day, tmp_night, .5, 
+					mainDisplay, Root), 
+				mainDisplay, Root);
+		civil_pix = GetColor(MixCharColors(tmp_day, tmp_night, .75, 
+					mainDisplay, Root), 
+				mainDisplay, Root);
+	} else {
+		day_pix = GetColor(state.sunrisetday, mainDisplay, Root);
+		night_pix = GetColor(state.sunrisetnight, mainDisplay, Root);
+		astro_pix = MixColors(state.sunrisetday, 
+				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);
+	}
+	oday_pix = GetColor(state.sunrisetday, mainDisplay, Root);
+	onight_pix = GetColor(state.sunrisetnight, mainDisplay, Root);
+	oastro_pix = MixColors(state.sunrisetday, 
 			state.sunrisetnight, .25, mainDisplay, Root);
-	naut_pix = MixColors(state.sunrisetday, 
+	onaut_pix = MixColors(state.sunrisetday, 
 			state.sunrisetnight, .5, mainDisplay, Root);
-	civil_pix = MixColors(state.sunrisetday, 
+	ocivil_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",
diff --git a/01_git/beo.astimerc b/01_git/beo.astimerc
index 266a27a..71a3c86 100644
--- a/01_git/beo.astimerc
+++ b/01_git/beo.astimerc
@@ -26,7 +26,7 @@ outThickness    1
 
 fancyHands      1
 outlinedHands   0
-neonHands       1
+neonHands       0
 
 #execProg        "xterm +sb -bg "#303030" -fg "#20b2aa" -geometry 80x50 -T top -n top -e top &"
 withdrawn       0
-- 
GitLab