本文整理匯總了Python中pygaze.screen.Screen.draw_rect方法的典型用法代碼示例。如果您正苦於以下問題:Python Screen.draw_rect方法的具體用法?Python Screen.draw_rect怎麽用?Python Screen.draw_rect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pygaze.screen.Screen
的用法示例。
在下文中一共展示了Screen.draw_rect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: EyeTribeTracker
# 需要導入模塊: from pygaze.screen import Screen [as 別名]
# 或者: from pygaze.screen.Screen import draw_rect [as 別名]
#.........這裏部分代碼省略.........
# skip further processing
continue
# get the calibration result if it was not obtained yet
if type(calibresult) != dict:
# empty display
self.disp.fill()
self.disp.show()
# allow for a bit of calculation time
clock.pause(2000)
# get the result
calibresult = self.eyetribe._tracker.get_calibresult()
# results
# clear the screen
self.screen.clear()
# draw results for each point
if type(calibresult) == dict:
for p in calibresult['calibpoints']:
# only draw the point if data was obtained
if p['state'] > 0:
# draw the mean error
self.screen.draw_circle(colour=(252,233,79), pos=(p['cpx'],p['cpy']), r=p['mepix'], pw=0, fill=True)
# draw the point
self.screen.draw_fixation(fixtype='dot', colour=(115,210,22), pos=(p['cpx'],p['cpy']))
# draw the estimated point
self.screen.draw_fixation(fixtype='dot', colour=(32,74,135), pos=(p['mecpx'],p['mecpy']))
# annotate accuracy
self.screen.draw_text(text=str(p['acd']), pos=(p['cpx']+10,p['cpy']+10), fontsize=12)
# if no data was obtained, draw the point in red
else:
self.screen.draw_fixation(fixtype='dot', colour=(204,0,0), pos=(p['cpx'],p['cpy']))
# draw box for averages
self.screen.draw_rect(colour=(238,238,236), x=int(self.dispsize[0]*0.15), y=int(self.dispsize[1]*0.2), w=400, h=200, pw=0, fill=True)
# draw result
if calibresult['result']:
self.screen.draw_text(text="calibration is successful", colour=(115,210,22), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25)), fontsize=12)
else:
self.screen.draw_text(text="calibration failed", colour=(204,0,0), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25)), fontsize=12)
# draw average accuracy
self.screen.draw_text(text="average error = %.2f degrees" % (calibresult['deg']), colour=(211,215,207), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25+20)), fontsize=12)
# draw input options
self.screen.draw_text(text="Press Space to continue, or 'R' to restart.", colour=(211,215,207), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25+40)), fontsize=12)
else:
self.screen.draw_text(text="Calibration failed, press 'R' to try again.")
# show the results
self.disp.fill(self.screen)
self.disp.show()
# wait for input
key, keytime = self.kb.get_key(keylist=['space','r'], timeout=None, flush=True)
# process input
if key == 'space':
calibrated = True
# calibration failed if the user quited
if quited:
return False
# NOISE CALIBRATION
# get all error estimates (pixels)
var = []
for p in calibresult['calibpoints']:
# only draw the point if data was obtained
if p['state'] > 0:
var.append(p['mepix'])
noise = sum(var) / float(len(var))
示例2:
# 需要導入模塊: from pygaze.screen import Screen [as 別名]
# 或者: from pygaze.screen.Screen import draw_rect [as 別名]
#scr.draw_ellipse()
scr.clear()
scr.draw_text("There should be two ellipses on the screen: \
\nred filled on the left, and green unfilled on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
scr.draw_ellipse(colour=(255,0,0), x=DISPSIZE[0]*0.25, y=DISPSIZE[1]/2, w=DISPSIZE[0]/10, h=DISPSIZE[0]/5, pw=5, fill=True)
scr.draw_ellipse(colour=(0,255,0), x=DISPSIZE[0]*0.75, y=DISPSIZE[1]/2, w=DISPSIZE[0]/10, h=DISPSIZE[0]/5, pw=5, fill=False)
disp.fill(scr)
disp.show()
kb.get_key()
#scr.draw_rect()
scr.clear()
scr.draw_text("There should be two rectangles on the screen: \
\nred filled on the left, and green unfilled on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
scr.draw_rect(colour=(255,0,0), x=DISPSIZE[0]*0.25, y=DISPSIZE[1]/2, w=DISPSIZE[0]/10, h=DISPSIZE[0]/5, pw=5, fill=True)
scr.draw_rect(colour=(0,255,0), x=DISPSIZE[0]*0.75, y=DISPSIZE[1]/2, w=DISPSIZE[0]/10, h=DISPSIZE[0]/5, pw=5, fill=False)
disp.fill(scr)
disp.show()
kb.get_key()
#scr.draw_line()
scr.clear()
scr.draw_text("There should be three lines on the screen: \
\nred oblique on the left, green horizontal in the centre, and blue vertical on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
scr.draw_line(colour=(255,0,0), spos=(DISPSIZE[0]*0.20,DISPSIZE[1]*0.45), epos=(DISPSIZE[0]*0.30,DISPSIZE[1]*0.55), pw=5)
scr.draw_line(colour=(0,255,0), spos=(DISPSIZE[0]*0.45,DISPSIZE[1]/2), epos=(DISPSIZE[0]*0.55,DISPSIZE[1]/2), pw=5)
scr.draw_line(colour=(0,0,255), spos=(DISPSIZE[0]*0.75,DISPSIZE[1]*0.45), epos=(DISPSIZE[0]*0.75,DISPSIZE[1]*0.55), pw=5)
disp.fill(scr)
disp.show()
kb.get_key()