我是python和psychopy的新手,我编写了一个“加载圈”,不幸的是我丢了太多帧。我正在使用 60 Hz 刷新率、全屏、没有互联网连接,并且计算机(MacBook Pro)足够强大。可能我的代码有问题(可能是每一帧中调用的 setVertices 方法),有人可以告诉我是否是这种情况,以及在psychopy中是否有替代方法来绘制加载圈(不丢帧太多)?非常感谢伊曼纽尔
from psychopy import visual,event
import numpy
import math
mywin = visual.Window([1280, 800],monitor="testMonitor",units="deg",fullscr = True,winType='pyglet')
cir = visual.ShapeStim(mywin,lineWidth = 4,lineColor = 'black',closeShape = False)
class circ(object):
def __init__(self,rad,size,centre):
self.rad = rad
self.size = size
self.centre = centre
self.points = numpy.arange(0,self.size, dtype = numpy.float)
def make_circle(self):
self.cx = self.centre[0]+(self.rad*numpy.cos(self.points*math.pi/(self.size/2)))
self.cy = self.centre[1]+(self.rad*numpy.sin(self.points*math.pi/(self.size/2)))
return numpy.array([self.cx,self.cy])
nFrames = 240
c = circ(3,nFrames,(0,0))
frames = numpy.zeros((nFrames,1),float)
coord = c.make_circle()
newpos=[]
for iframe in range(nFrames):
newpos.append([coord[0,iframe],coord[1,iframe]])
cir.setVertices(newpos)
cir.draw()
frames[iframe] = mywin.flip()
print numpy.diff(frames,axis = 0)*1000