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