From 54543cf2506577f77e93443de3d5ba86d5f773c3 Mon Sep 17 00:00:00 2001 From: siflfran <siflfran> Date: Mon, 1 May 2006 22:05:50 +0000 Subject: [PATCH] draw_dial() neu implementiert --- 01_git/astime_x.c | 275 +++++++++++----------------- 01_git/autoconf/Makefile.defines.in | 4 +- 01_git/beo.astimerc | 2 +- 3 files changed, 107 insertions(+), 174 deletions(-) diff --git a/01_git/astime_x.c b/01_git/astime_x.c index ab1666f..ce63be7 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -117,8 +117,13 @@ void draw_sunriset(Window win, float size, int type); void draw_window(Window win); +/* convert the position on 0-60 scale into xy coordinates */ inline float convert2x(float tim); inline float convert2y(float tim); +/* convert time units to degrees * 64 */ +inline short hour_to_deg64(unsigned short hour); +inline short min_to_deg64(unsigned short hour); +inline short sec_to_deg64(unsigned short hour); void constants(void); void calculate_hands(void); void refresh(void); @@ -472,7 +477,6 @@ void draw_window(Window win) } } -/* convert the position on 0-60 scale into xy coordinates */ inline float convert2x(float tim) { return cos(M_PI * (((tim - 15)) * 6) / 180); @@ -482,6 +486,25 @@ inline float convert2y(float tim) return sin(M_PI * (((tim - 15)) * 6) / 180); } +inline short hour_to_deg64(unsigned short hour) +{ + if (state.twentyfour) { + return (hour * 960) % 23040; + } else { + return (hour * 1920) % 23040; + } +} + +inline short min_to_deg64(unsigned short min) +{ + return min * 384; +} + +inline short sec_to_deg64(unsigned short sec) +{ + return sec * 384; +} + float hwidth[3]; float hlength[3]; float hback[3]; @@ -719,132 +742,41 @@ void update(void) */ void draw_dial(void) { - float tmp, tinc; - struct coordinates tmp_coord; + short base_size, i; float xrate, yrate; - - mainGCV.foreground = fore_pix; - XChangeGC(mainDisplay, mainGC, GCForeground, &mainGCV); - - switch (state.tprop) { - case 2: - tinc = 1.0; - break; - case 1: - if (state.twentyfour) { - tinc = 2.5; - } else { - tinc = 5.0; - } - break; - case 0: - tinc = 60.0; - break; - default: - tinc = 1.0; - break; - } - - if (state.tprop) { - for (tmp = 0.0; tmp < 60.0; tmp += tinc) { - xrate = convert2x(tmp); - yrate = convert2y(tmp); - tmp_coord.x = rint((watch_size.x + 1) * xrate) + center.x; - tmp_coord.y = rint((watch_size.y + 1) * yrate) + center.y; -#ifdef DEBUG - printf("dot at %d %d\n", tmp_coord.x, tmp_coord.y); -#endif - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - tmp_coord.x, - tmp_coord.y); + XPoint coord; + + 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]; + size = fmax(base_size * 3, 6); + } else if (state.twentyfour ? i % 5 == 0 : i % 10 == 0) { + mainGCV.foreground = pix[7]; + size = fmax(base_size * 2, 4); + } else if (i % 2 == 0) { if (state.tprop == 2) { - if (!((int) tmp % 5)) { - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - tmp_coord.x, - tmp_coord.y + 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - tmp_coord.x + 1, - tmp_coord.y); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - tmp_coord.x, tmp_coord.y - 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - tmp_coord.x - 1, - tmp_coord.y); - } + mainGCV.foreground = pix[6]; + size = base_size; + } else { + continue; } + } else { + continue; } - - if (state.tprop == 1) { - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x - watch_size.x - 1, - center.y - 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x - watch_size.x - 1, - center.y + 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x - watch_size.x, - center.y); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x + watch_size.x + 1, - center.y - 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x + watch_size.x + 1, - center.y + 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x + watch_size.x, - center.y); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x - 1, - center.y - watch_size.y - 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x + 1, - center.y - watch_size.y - 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x, - center.y - watch_size.y); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x - 1, - center.y + watch_size.y + 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x + 1, - center.y + watch_size.y + 1); - XDrawPoint(mainDisplay, - backgroundWindow, - mainGC, - center.x, - center.y + watch_size.y); + 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); + } else { + FillTriangle(mainDisplay, backgroundWindow, mainGC, + coord.x, coord.y, size, rint(.5 * size), + sec_to_deg64(60 - i / 2.0)); } } } @@ -1286,54 +1218,8 @@ void initialize(int argc, char **argv, state.total_size.y - 1 ); } - - /* Finish up the background (the dial) */ - draw_dial(); - - status = XSetCommand(mainDisplay, mainWindow, argv, argc); - - /* Set up the event for quitting the window */ - wm_delete_window = XInternAtom(mainDisplay, - "WM_DELETE_WINDOW", /* atom_name */ - False /* only_if_exists */ - ); - wm_protocols = XInternAtom(mainDisplay, - "WM_PROTOCOLS", /* atom_name */ - False /* only_if_exists */ - ); - status = XSetWMProtocols(mainDisplay, - mainWindow, - &wm_delete_window, - 1 - ); - status = XSetWMProtocols(mainDisplay, - iconWindow, - &wm_delete_window, - 1 - ); - - WmHints.flags = StateHint | IconWindowHint; - WmHints.initial_state = - withdrawn ? WithdrawnState : - iconic ? IconicState : NormalState; - WmHints.icon_window = iconWindow; - if (withdrawn) { - WmHints.window_group = mainWindow; - WmHints.flags |= WindowGroupHint; - } - if (iconic || withdrawn) { - WmHints.icon_x = SizeHints.x; - WmHints.icon_y = SizeHints.y; - WmHints.flags |= IconPositionHint; - } - XSetWMHints(mainDisplay, - mainWindow, - &WmHints); - - /* Finally show the window */ - status = XMapWindow(mainDisplay, mainWindow); - - /* Get colors while waiting for Expose */ + + /* Get colors */ if (state.neon) { pix[0] = DarkenColor(state.seccolor, 1.8, mainDisplay, Root); pix[1] = DarkenColor(state.mincolor, 1.8, mainDisplay, Root); @@ -1379,6 +1265,53 @@ void initialize(int argc, char **argv, /* Get the label color */ label_pix = GetColor(state.label_color, mainDisplay, Root); + /* Finish up the background (the dial) */ + if (state.tprop) { + draw_dial(); + } + status = XSetCommand(mainDisplay, mainWindow, argv, argc); + + /* Set up the event for quitting the window */ + wm_delete_window = XInternAtom(mainDisplay, + "WM_DELETE_WINDOW", /* atom_name */ + False /* only_if_exists */ + ); + wm_protocols = XInternAtom(mainDisplay, + "WM_PROTOCOLS", /* atom_name */ + False /* only_if_exists */ + ); + status = XSetWMProtocols(mainDisplay, + mainWindow, + &wm_delete_window, + 1 + ); + status = XSetWMProtocols(mainDisplay, + iconWindow, + &wm_delete_window, + 1 + ); + + WmHints.flags = StateHint | IconWindowHint; + WmHints.initial_state = + withdrawn ? WithdrawnState : + iconic ? IconicState : NormalState; + WmHints.icon_window = iconWindow; + if (withdrawn) { + WmHints.window_group = mainWindow; + WmHints.flags |= WindowGroupHint; + } + if (iconic || withdrawn) { + WmHints.icon_x = SizeHints.x; + WmHints.icon_y = SizeHints.y; + WmHints.flags |= IconPositionHint; + } + XSetWMHints(mainDisplay, + mainWindow, + &WmHints); + + /* Finally show the window */ + status = XMapWindow(mainDisplay, mainWindow); + /* try to read the time */ curTime = time(0); last_time = curTime; diff --git a/01_git/autoconf/Makefile.defines.in b/01_git/autoconf/Makefile.defines.in index 226488e..4f23495 100644 --- a/01_git/autoconf/Makefile.defines.in +++ b/01_git/autoconf/Makefile.defines.in @@ -3,7 +3,7 @@ # CC = @CC@ -CCFLAGS = @CFLAGS@ -std=c99 -DNDEBUG -D_BSD_SOURCE -D_XOPEN_SOURCE=600 -Wall -Werror -pedantic-errors +CCFLAGS = @CFLAGS@ -std=c99 -DNDEBUG -D_BSD_SOURCE -D_XOPEN_SOURCE=600 -D_ISO99_SOURCE -Wall -Werror -pedantic-errors #CCFLAGS += -W -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wno-variadic-macros -Wold-style-definition RANLIB = @RANLIB@ AR = ar clq @@ -33,7 +33,7 @@ LIBS_JPEG = @JPEG_LIB@ LIBS_XEXTS = LIBS_AFTERSTEP = LIBS_M = -lm -LIBRARIES = $(LIBS_X) $(LIBS_XPM) $(LIBS_JPEG) $(LIBS_XEXTS) $(LIBS_AFTERSTEP) $(LIBS_M) +LIBRARIES = $(LIBS_X) $(LIBS_XPM) $(LIBS_JPEG) $(LIBS_XEXTS) $(LIBS_AFTERSTEP) $(LIBS_M) -lbsd-compat AFTER_BIN_DIR = @bindir@ AFTER_MAN_DIR = @mandir@/man1 diff --git a/01_git/beo.astimerc b/01_git/beo.astimerc index 23e5536..9aa0385 100644 --- a/01_git/beo.astimerc +++ b/01_git/beo.astimerc @@ -42,7 +42,7 @@ title astime twentyfourHour 1 sunriset 1 -sunrisetDay green +sunrisetDay orange sunrisetNight black latitude 11.05 longitude 49.6972222 -- GitLab