Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 994d853

Browse files
committed
Choose the smallest value of x,y for the clock's radius (instead of just taking the
y coordinate), and change radius of second indicator to compensate Remove redundant setting of sradius
1 parent 49d27c8 commit 994d853

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

Demo/curses/tclock.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,22 @@ def main(win):
8080

8181
cx = (curses.COLS - 1) / 2
8282
cy = curses.LINES / 2
83-
if cx > cy:
84-
ch = cy
85-
else:
86-
ch = cx
87-
mradius = (3 * cy) / 4
88-
hradius = cy / 2
89-
sradius = (2 * cy) / 3
83+
ch = min( cy-1, int(cx / ASPECT) - 1)
84+
mradius = (3 * ch) / 4
85+
hradius = ch / 2
86+
sradius = 5 * ch / 6
9087

9188
for i in range(0, 12):
9289
sangle = (i + 1) * 2.0 * pi / 12.0
93-
sradius = 5 * cy / 6
9490
sdx, sdy = A2XY(sangle, sradius)
9591

9692
stdscr.addstr(cy - sdy, cx + sdx, "%d" % (i + 1))
9793

9894
stdscr.addstr(0, 0,
9995
"ASCII Clock by Howard Jones <[email protected]>, 1994")
10096

101-
sradius = 8
97+
sradius = max(sradius-4, 8)
98+
10299
while 1:
103100
curses.napms(1000)
104101

0 commit comments

Comments
 (0)