fixed sizing bug

This commit is contained in:
ville rantanen
2013-04-04 14:57:20 +03:00
parent c433b6370c
commit bff8991803

View File

@@ -14,13 +14,19 @@ def centerpoint(ry,rx):
r=int(round(min(ry/1.5,rx/1.5))-1)
return (int(round(ry/2)),int(round(rx/2)),r)
def saddstr(win,y,x,s):
try:
win.addstr(y,x,s)
except:
pass
def drawcircle(win,cy,cx,r):
precision=360
for a in range(precision):
alpha=2.0*math.pi*a/precision
dy=int(round(cy-float(r)*math.cos(alpha)))
dx=int(round(cx+2.0*float(r)*math.sin(alpha)))
win.addstr(dy,dx,'.')
saddstr(win,dy,dx,'.')
return
def drawline(win,cy,cx,a,r,char):
@@ -29,7 +35,8 @@ def drawline(win,cy,cx,a,r,char):
if l>1:
ly=int(round(cy-float(l)*math.cos(a)/prec))
lx=int(round(cx+1.8*float(l)*math.sin(a)/prec))
win.addstr(ly,lx,char)
saddstr(win,ly,lx,char)
return
def drawdigit(win,y,x,d):
@@ -63,7 +70,7 @@ def drawsplitstr(win,y,x,st):
ls=list(st)
for r in range(5):
rs=3*r
win.addstr(y+r,x,ls[rs]+ls[rs+1]+ls[rs+2])
saddstr(win,y+r,x,ls[rs]+ls[rs+1]+ls[rs+2])
return
def drawdigital(win,y,x,t):
@@ -84,9 +91,10 @@ def main():
stdscr=curses.initscr()
curses.curs_set(0)
try:
rows,columns = termsize()
cy,cx,r = centerpoint(rows,columns)
#rows,columns = termsize()
while (1):
rows,columns = stdscr.getmaxyx()
cy,cx,r = centerpoint(rows,columns)
stdscr.clear()
t=time.localtime()
alphas=math.pi*float(t.tm_sec)/30.0
@@ -102,7 +110,7 @@ def main():
stdscr.refresh()
time.sleep(options.refresh)
except:# KeyboardInterrupt:
except KeyboardInterrupt:
curses.nocbreak()
stdscr.keypad(0)
#curses.echo()