fun with clock
This commit is contained in:
@@ -47,9 +47,11 @@ def centerpoint(ry, rx):
|
||||
return (int(round(ry / 2)), int(round(rx / 2)), r)
|
||||
|
||||
|
||||
def saddstr(win, y, x, s):
|
||||
def saddstr(win, y, x, s, a=None):
|
||||
if not a:
|
||||
a=curses.color_pair(0)
|
||||
try:
|
||||
win.addstr(y, x, s)
|
||||
win.addstr(y, x, s, a)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -64,13 +66,13 @@ def drawcircle(win, cy, cx, r):
|
||||
return
|
||||
|
||||
|
||||
def drawline(win, cy, cx, a, s, r, char):
|
||||
def drawline(win, cy, cx, a, s, r, char, attr=None):
|
||||
prec = 2
|
||||
for l in range(int(r * prec)):
|
||||
if l > s:
|
||||
ly = int(round(cy - float(l) * math.cos(a) / prec))
|
||||
lx = int(round(cx + 2.0 * float(l) * math.sin(a) / prec))
|
||||
saddstr(win, ly, lx, char)
|
||||
saddstr(win, ly, lx, char, attr)
|
||||
|
||||
return
|
||||
|
||||
@@ -130,6 +132,10 @@ class timer_struct:
|
||||
def main():
|
||||
stdscr = curses.initscr()
|
||||
curses.curs_set(0)
|
||||
curses.start_color()
|
||||
curses.use_default_colors()
|
||||
for i in range(0, curses.COLORS):
|
||||
curses.init_pair(i + 1, i, -1)
|
||||
start_t = time.time()
|
||||
try:
|
||||
# rows,columns = termsize()
|
||||
@@ -150,9 +156,9 @@ def main():
|
||||
alpham = math.pi * t_m / 30.0 + alphas / 60.0
|
||||
alphah = math.pi * t_h / 6.0 + alpham / 12.0
|
||||
if options.seconds:
|
||||
drawline(stdscr, cy, cx, alphas, 1, r / 2, "s")
|
||||
drawline(stdscr, cy, cx, alpham, 1, int(round(r * 0.8) / 2), "m")
|
||||
drawline(stdscr, cy, cx, alphah, 1, int(round(r * 0.5) / 2), "HH")
|
||||
drawline(stdscr, cy, cx, alphas, 1, r / 2, "s", curses.color_pair(2))
|
||||
drawline(stdscr, cy, cx, alpham, 1, int(round(r * 0.8) / 2), "m", curses.color_pair(3))
|
||||
drawline(stdscr, cy, cx, alphah, 1, int(round(r * 0.5) / 2), "HH", curses.color_pair(7))
|
||||
stdscr.addstr(cy, cx, "o")
|
||||
drawcircle(stdscr, cy, cx, r / 2)
|
||||
for h in range(12):
|
||||
|
||||
Reference in New Issue
Block a user