本文整理匯總了Python中pygaze.screen.Screen.draw_line方法的典型用法代碼示例。如果您正苦於以下問題:Python Screen.draw_line方法的具體用法?Python Screen.draw_line怎麽用?Python Screen.draw_line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pygaze.screen.Screen
的用法示例。
在下文中一共展示了Screen.draw_line方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: range
# 需要導入模塊: from pygaze.screen import Screen [as 別名]
# 或者: from pygaze.screen.Screen import draw_line [as 別名]
tracker.calibrate()
# starting screen
scr.clear()
scr.draw_text(text="Press Space to start")
disp.fill(scr)
disp.show()
kb.get_key(keylist=['space'], timeout=None, flush=True)
# # # # #
# VALIDATION horizontal
scr.clear()
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.15*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.15*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.95*DISPSIZE[0]),int(0.15*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.5*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.95*DISPSIZE[0]),int(0.5*DISPSIZE[1])), (int(0.05*DISPSIZE[0]),int(0.5*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.5*DISPSIZE[1])), (int(0.05*DISPSIZE[0]),int(0.85*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.85*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.85*DISPSIZE[1])), 1)
# loop through points
for i in range(len(CALIBPOINTShor)):
# get coordinate
x, y = CALIBPOINTShor[i]
# draw calibration point
scr.draw_fixation(fixtype='cross', pos=(x,y))
disp.fill(scr)
disp.show()
示例2:
# 需要導入模塊: from pygaze.screen import Screen [as 別名]
# 或者: from pygaze.screen.Screen import draw_line [as 別名]
#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()
#scr.draw_polygon()
scr.clear()
scr.draw_text("There should be two polygons on the screen: \
\nred filled triangle on the left, and green unfilled hexagon on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
pl = [(DISPSIZE[0]*0.25, DISPSIZE[1]*0.45), (DISPSIZE[0]*0.2, DISPSIZE[1]*0.55), (DISPSIZE[0]*0.3, DISPSIZE[1]*0.55)]
scr.draw_polygon(pl, colour=(255,0,0), pw=5, fill=True)
# topleft, topright, centreright, bottomright, bottomleft, centreleft
pl = [(DISPSIZE[0]*0.70, DISPSIZE[1]*0.40), (DISPSIZE[0]*0.80, DISPSIZE[1]*0.40), (DISPSIZE[0]*0.85, DISPSIZE[1]*0.5), (DISPSIZE[0]*0.80, DISPSIZE[1]*0.60), (DISPSIZE[0]*0.70, DISPSIZE[1]*0.60), (DISPSIZE[0]*0.65, DISPSIZE[1]*0.5)]
scr.draw_polygon(pl, colour=(0,255,0), pw=5, fill=False)
示例3: EyeTribeTracker
# 需要導入模塊: from pygaze.screen import Screen [as 別名]
# 或者: from pygaze.screen.Screen import draw_line [as 別名]
#.........這裏部分代碼省略.........
self.disp.fill(self.screen)
self.disp.show()
# get input
key, keytime = self.kb.get_key(keylist=['q','space'], timeout=None, flush=True)
if key == 'space':
# unset quited Boolean
quited = False
# skip further processing
continue
# empty display
self.disp.fill()
self.disp.show()
# allow for a bit of calculation time
# (this is waaaaaay too much)
clock.pause(1000)
# get the calibration result
self.eyetribe._lock.acquire(True)
calibresult = self.eyetribe._tracker.get_calibresult()
self.eyetribe._lock.release()
# 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)
self.screen.draw_line(spos=(p['cpx'],p['cpy']),
epos=(p['mecpx'],p['mecpy']), pw=2)
# 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='%.2f' % p['acd'],
pos=(p['cpx']+10,p['cpy']+10), fontsize=20)
# 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 successful",
colour='green',
pos=(int(self.dispsize[0]*0.5), int(self.dispsize[1]*0.25)),
fontsize=20)
else:
self.screen.draw_text(text="Calibration failed",
colour='red',
pos=(int(self.dispsize[0]*0.5),int(self.dispsize[1]*0.25)),
fontsize=20)
# draw average accuracy
self.screen.draw_text(
text="Average error = %.2f degrees" % (calibresult['deg']),
pos=(int(self.dispsize[0]*0.5),int(self.dispsize[1]*0.25+30)),
fontsize=20)